Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 73/378 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • 400 error when submitting tumblr post (ruby on rails)

    - by Matenia Rossides
    I am having a bit of an issue with getting tumblr working within a rails app. This is the snippet of code which results in a 400 error (meaning that there was an incorrect parameter) @postcontent = @post.content.gsub(/<\/?[^>]*>/, "") post = Tumblr::Post.create(:email => 'valid@email', :password => 'mypassword', :type => 'video', :embed = @post.video_html, :caption = @postcontent) I have checked the API docs and checked my code and code content being rendered, and it still does not want to work. The funny thing is that it worked previously. It was working about a week ago. Has something changed with tumblr?

    Read the article

  • Rails: form input type and getting the filename

    - by Shyam
    Hi, As I am using Ruby on Rails to build an application, which only runs locally, I am lost in the woods (a nuby without a compass). I have a simple MVC application and my view is missing one thing I could really use. I want to select a local file just to retrieve it's filename. I know it's relatively easy to use the form tag helpers for uploading: <%= file_field 'upload', 'datafile' %></p> I wonder how I could get the filename from the selected file, without uploading the file.

    Read the article

  • Rails - Trying to query from a date range...everything from today

    - by ChrisWesAllen
    I'm trying to figure the best way to query a date range from rails...I looked around on Google but am unsure about how to use this syntax. I have a Model that has various events and I like to add to my find condition a caveat that should only show events where the field :st_date is today or later, in effect only show me data that is current, nothing that happened before today. I ran into a problem because I have no end date to stop the query, I want to query everything from today to next month. I was thinking something like @events = Event.find(:all, :conditions => ["start_date between ? and ?", date.Today, date.next_month.beginning_of_month]) but I get the error undefined local variable or method `date'...... Do I need do anything particular to use the Date class? Or is there something wrong with my query syntax? I would really appreciate any help.

    Read the article

  • Converting old Mailer to Rails 3 (multipart/mixed)

    - by Oscar Del Ben
    I'm having some difficulties converting this old mailer api to rails 3: content_type "multipart/mixed" part :content_type => "multipart/alternative" do |alt| alt.part "text/plain" do |p| p.body = render_message("summary_report.text.plain.erb", :message = message.gsub(/<.br./,"\n"), :campaign=campaign, :aggregate=aggregate, :promo_messages=campaign.participating_promo_msgs) end alt.part "text/html" do |p| p.body = render_message("summary_report.text.html.erb", :message = message, :campaign=campaign, :aggregate=aggregate,:promo_messages=campaign.participating_promo_msgs) end end if bounce_path attachment :content_type => "text/csv", :body=> File.read(bounce_path), :filename => "rmo_bounced_emails.csv" end attachment :content_type => "application/pdf", :body => File.read(report_path), :filename=>"rmo_report.pdf" In particular I don't understand how to differentiate the different multipart options. Any idea?

    Read the article

  • How do you unpack gems using jruby on rails 2.3?

    - by James Moore
    I'm trying to unpack all the system gems to end up with a standalone Rails directory including all the rails gems and all the system gems. I'm starting with a bare rails setup; just did a jruby -S rails and a 'generate jdbc'. I then add a config.gem 'jdbc-mysql' to environment.rb and do the jruby -S rake gems:unpack:dependencies. After unpacking, if I do a rake I get: no such file to load -- jdbc-mysql Is there something else you need to do to get the jdbc gem unpacked? I'm using jruby 1.4.0 (and moving to 1.5 is on my todo list) and rails 2.3.8.

    Read the article

  • Large file download for a Rails project

    - by Horace Ho
    One client project will be online two months later. One of the requirements changed is to support large files (10 to 15MB per RAW camera file, expected 1000 to 5000 files download per day) download worldwide for their customers. The process will be: there is upload screen via paperclip to the rails local public folder a hourly task to upload to web storage (S3?) update the download url from paperclip url to the web url Questions: is there a gem/plug-in for this purpose? if no, any gem/plug-in for S3 to recommend? Questions about the storage provider: is S3 recommended? or other service to recommend? The baseline is: the client's web server does not and will not have the bandwidth to handle the downloads. Thanks

    Read the article

  • ruby on rails regular expression to remove html tags and its content from text

    - by salilgaikwad
    Hi All, I want regular expression in ruby on rails which remove all the html tags and its content from the given text. For example if my text is :-INPUT :- <span id="span_is"><br><br><u><i>Hi</i></u></span> then it should display only OUTPUT should be as follows:- Hi in short i want regular expression or a function which remove < and whatever the content between <. Thanks & Regards, Salil Gaikwad

    Read the article

  • Question about Paperclip for Rails

    - by sev
    I'm using Papeclip(2.3.1.1) with Rails(2.3.5). In my view I write so: <%= link_to image_tag(p.attachment.url(:small)), p.attachment.url(:original) %, and it becomes into href="/system/attachments/1/original/1.JPG?1270134617 (for a tag) src="/system/attachments/1/small/1.JPG?1270134617" (for img tag). And when I click on the picture, my browser (Firefox) offers me to save or open picture and I want to just open picture in browser without any dialogs. I think it's because link contains ?1270134617 after file's name. How can I fix it?

    Read the article

  • [Rails] HTTP Get Request

    - by Karl
    I've been trying to get Rails to play with the new Facebook Graph API. After I get the authorization "code", I need to send another request which returns the access token in JSON form. It seems to work fine, however I want to fetch the access token JSON without redirecting the user. I'm attempting to use Net::HTTP.get, but I'm not sure how to use it to get a request body, or even if it's the right thing to use to begin with. Can anyone give an example of performing an HTTP GET?

    Read the article

  • Ruby on Rails - Send JavaScript to view

    - by Eef
    Hey, I am creating a website in Ruby on Rails. I have a controller action that renders a view like so: def show time_left = Time.now.to_i - 3.hours.to_i @character = current_user.characters.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @character } end end This is fine as it renders the show.html.erb as I like. I would like however to somehow pass time_left to the view as a Javascript variable as this value is use by a countdown JQuery plugin. I could put a javascript block on the page in the HTML and print a instance variable out like so: <script type="javascript"> $('#countdown').countdown('<%= @time_left =>')</script> But I would like to keep all my JS in a external file and off the page could anyone give some advice on how to implement this? Cheers Eef

    Read the article

  • Relation/Sort not working in rails controller?

    - by Elliot
    I have the following relation in my rails app: genre - has many - authors authors - belong to genre and has many books books - belongs to authors and belongs to users (users can add books to the db) in my controller I have: @books=current_user.books(:include => [:author => :genre], :order => 'created_at DESC') While I am able to use the @books variable in my views - nothing is done correctly (i.e. its not showing me only books added by that user, and its not descending by created_at)... any ideas? -- Also I'm using clearance for the user auth, so current_user without the @ in the controller seems to work fine Actually, I think the relation is working, only the sort might not be working...

    Read the article

  • Using unless in rails uniqueness validation

    - by dunxd
    I am just starting out in Rails, and trying to develop a simple application. I need to validate three values submitted to the application - each must meet the same validation criteria. The validation is pretty simple: Value is valid if unqiue, null or equal to "p" or "d". The following gets me halfway there: validates_uniqueness_of :value1, :value2, :value3, :allow_nil => true I think I can use :unless to check whether the value is either "p" or "d", however I can't figure out how. I guess I am trying to combine validates_uniqueness_of with validates_inclusion_of. Any suggestions?

    Read the article

  • Gem::Install Error

    - by Tian
    When I try to cleanup my rails versions with sudo gem cleanup rails I get the following error: Cleaning up installed gems... Attempting to uninstall rails-2.3.5 Unable to uninstall rails-2.3.5: Gem::InstallError: cannot uninstall, check `gem list -d rails` Attempting to uninstall rails-1.2.6 Unable to uninstall rails-1.2.6: Gem::InstallError: cannot uninstall, check `gem list -d rails` gem list -d rails results in: rails (2.3.8, 2.3.5, 1.2.6) Author: David Heinemeier Hansson Rubyforge: http://rubyforge.org/projects/rails Homepage: http://www.rubyonrails.org Installed at (2.3.8): /Library/Ruby/Gems/1.8 (2.3.5): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 (1.2.6): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 Web-application framework with template engine, control-flow layer, and ORM. Any one know what's wrong?

    Read the article

  • Rails - Permission denied when try to save uploaded file in windows

    - by logoin
    I'm writing my own file upload in rails. I saw some related questions but it doesn't answer my question. I use File.open ("#{RAILS_ROOT}/public/docs/attachments/#{@file_name}", "wb") {|f| f.write(@temp_file.read)} to write the file on my local machine (OS: Windows XP) instead of saving it in database. I got a Permission denied error on the File.open method. Since I have cygwin installed, I chmod 777 the folder that files should write to and also make sure the file I upload can be read. But I'm still getting the same error. Any ideas? Thanks!

    Read the article

  • Rails - JSON object with an array?

    - by AnApprentice
    Hello, I'm able to create and send a JSON object like so: @mylist << { :id => item.id, :name => name.id } render :json => { :result => 'success', :mylist => @mylist } That works great. Problem I'm having now is that I need to include users with are 1 or more per item. @mylist << { :id => item.id, :name => name.id, :users => item.users } Where item.users contains a list of (user.id, user.name, user.desc). how do I include an array like users inside a json object? How to build in Rails and then how to parse it with jQuery? Thanks

    Read the article

  • Rails belongs_to issue in the views

    - by Jacobo Tibaquira
    Hi, Im having problems with an association in rails: Currently I have Post and User models, and the relationship is set this way: class User < ActiveRecord::Base attr_accessible :username, :name, :lastname has_many :posts end class Post < ActiveRecord::Base attr_accessible :title, :body belongs_to :user end However, in my app/views/posts/index.html.haml when Im trying to access the username for the post I get this error: undefined method `name' for nil:NilClass This is my view: - title "Posts" %table %tr %th Title %th Body %th Author - for post in @posts %tr %td= h post.title %td= h post.body %td= h post.user.name %td= link_to 'Show', post %td= link_to 'Edit', edit_post_path(post) %td= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %p= link_to "New Post", new_post_path Any thoughts of what Im doing wrong will be appretiated

    Read the article

  • Rails application and multilingual content, Model dilemma

    - by dakull
    I'm writing in Rails a website that will be multilingual, for the application translation part i will use the simple I18n gem, for messages and everything related. Yet, all the content must be translated, and we're talking about lots of pages, that will be stored into the database ( like articles, news, etc. ) For now, I'm thinking of two approaches: Lets say i have a Pages table, the content in diff. languages, i will be storing it in a different table called PagesContent that will belong_to Pages and also to a Languages table. The problem here, is that I'll essentially duplicate the no. of tables needed. Pros: flexibility, in the box validation To skip that duplication i can serialize a hash into the content column of Pages, containing the translation. The problem here, is validation, arguably more code to write, and less flexibility when adding a new language. Pros: Less tables. Any other idea ?

    Read the article

  • Modifying a MySQL database on a Ruby on Rails install

    - by James W
    Hello, sorry if this questions is overly basic or has been asked before but I simply cannot figure it out. On my Ruby on Rails site, I have a controller that accesses the fields of a table in my database and displays their "Name" field as a drop-down menu in one of my views. My problem is I need to change the options of that dropdown menu so I need a way to get into the MySQL database and change the values of those fields. Anyone know of a way to do this? It would be much appreciated. Thank you.

    Read the article

  • Encryption-Decryption in Rails

    - by Salil
    Hi All, I am using require 'digest/sha1' to encrypt my password and save into database. During login I authenticate by matching the encrypted password saved in database and again encrypted the one use enter in password field. As of now everything works fine but now I want to do 'Forgot Password' functionality. To do this I need to decrypt the password which is saved in database to find original one. How to decrypt using digest/sha1? Or does anyone know any algorithm which supports encryption & decryption as well? I am using ruby on rails so I need Ruby way to accomplish it.

    Read the article

  • Eager load this rails association

    - by dombesz
    Hi, I have rails app which has a list of users. I have different relations between users, for example worked with, friend, preferred. When listing the users i have to decide if the current user can add a specific user to his friends. -if current_user.can_request_friendship_with(user) =add_to_friends(user) -else =remove_from_friends(user) -if current_user.can_request_worked_with(user) =add_to_worked_with(user) -else =remove_from_worked_with(user) The can_request_friendship_with(user) looks like: def can_request_friendship_with(user) !self.eql?(user) && !self.friendships.find_by_friend_id(user) end My problem is that this means in my case 4 query per user. Listing 10 users means 40 query. Could i somehow eager load this?

    Read the article

  • Rails diff model config in dev or prod environment

    - by Denis
    Hi, I've a model which use paperclip, in dev env I want to store files on the file system. In production I want to store them on my s3 account. How to configure my model to reflet this difference? Here is my model class Photo < ActiveRecord::Base has_attached_file :photo, :styles => { :medium => "200x200>", :thumb => "100x100>" }, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => "/:style/:filename" end

    Read the article

  • How to implement a mailing system with Rails that sends emails in the background

    - by Tam
    I want to implement a reliable mailing system with Ruby on Rails that sends emails in the background as sending email sometimes takes like 10 seconds or more so I don't want the user to wait. Some ideas I thought of: 1- Write to a table in DB a have a background process that go over and send email (concern: potential many reads/writes to DB slows down my application) 2- Messaging Queue background process / Rake task (concern: if server crashes queued mails will be lost also might eat up a lot of memory if many emails) I was wondering if you a know of a good solution that provides a balance between reliability and performance.

    Read the article

  • rails contoller defaults to respond with application/xml in production

    - by Dave Paroulek
    I have a standard contacts_controller.rb with index action that responds as follows: respond_to do |format| format.html format.xml { render :xml => @contacts } end In development, it works as intended: when I browse to http://localhost:3000/contacts, I get an html response. But, when I start the app using capistrano on a remote ubuntu server and browse to the same url, I get a xml response? If I go to http://remote_host:8000/contacts.html, then I see the html response. If I comment out the format.xml { render :xml => @contacts }, then I see the desired html response. Pretty sure I'm missing something subtle about difference between rails development and production modes? Any ideas about what I'm overlooking? Thanks, - Dave

    Read the article

  • How do I get rid of extra lines in my output from Rails

    - by Dan B
    I am using Rails 2.1 to output tables from a database. But the output includes lots of extra lines and tabs. I am using a while loop with lots of nested if statements. I am also wrapping all of my non-output lines in <%- code -%. Any idea what might be happening and a solution? Thanks, ex: <tr> <td>Some data</td> <td>more data</td>

    Read the article

  • rails migration. modify starting point for auto_increment

    - by railsnew
    I have a table already created. I am looking for a rails migration where I can modify the starting point of the auto_increment number for id column of my table. Let's say I want it to start from 1000. I googled a bit and came across this: it says: :options "string" pass raw options to your underlying database, e.g. auto_increment = 10000. Note that passing options will cause you to lose the default ENGINE=InnoDB statement Can this be used for something I want? and how will the migration look since i am changing the column and not creating new one...

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >