RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

The current select2-rails gem has 114 downloads so far, if it helps you. :)

Avatar

I think you need "%" like this if you try the last tutorial .

ruby
class CategoriesController < ApplicationController
  def index
    @categories = Category.order(:name).where("name like ?", "%#{params[:term]}%")
    render json: @categories.map(&:name)
  end
end
Avatar

I'm getting an error when I first run cap deploy. I have put up the error I'm getting here but can't seem to find the soloution anywhere.

Error with cp

Any ideas?

Avatar

Finally fixed it. I forgot to replace a couple other 'blog' with 's. I wasn't specifically able to push the change out by updating the unicorn.rb file. I ended up renaming the 'unicorn.blog.sock' and that fixed it.

Avatar

He means that its annoying to use "libpq" instead of "libpg" (the average joe won't know that thats the name of the library) - not the "-dev" part.

Avatar

Thank you for this excellent episode! One of the most eye-opening ever.

Avatar

Is there a way to view a log output from Unicorm like WEBrick? My app is deploying correctly, but isn't running correctly off the sever. I'm just getting the useless error pages.

Avatar

Great tutorial. I'm new to Rails development. I'm finally making the switch from PHP to Ruby! And all of your videos are helping out immensely. Thanks so much.

Avatar

The information for implementing cancan hasn't really changed much for Rails 3. You can check out the wiki for cancan, which is what I recently used to get it up and running on my app: CanCan wiki

Avatar

cool site. has already proven to be extremely useful for me as i have been scoping out ipad cases recently, and came across this: http://www.kickstarter.com/projects/552506690/brydge-ipad-do-more

Avatar

I am having an error, that gets caught on the browser:
Uncaught TypeError: Object [object Object] has no method 'up'

On the line:

application.js
...
$(link).up().insert({ 
before: content.replace(regexp, new_id)
});
...

What might possibly be the cause for this?? I already saw both railcast and source code, but cannot find the solution

I am getting pretty frustrated on this! I would really appreciate some help here! thanks

Avatar

Love these revised episodes. Would really like to see the episode on Cancan revised. :)

Avatar

I wish CodeRay had a CoffeeScript scanner. That's really the only thing that tempts me to switch to Pygments.

Avatar

Can you please tell me how did you resolve this issue. I am using Devise for Authentication and I am getting this error.

I had loaded the entire database through the schema.rb thereby not requiring any migrations to be run. But still I am facing the same issue.

Please help me resolve this issue as I am stuck with this from the past few days and unable to deploy my application on heroku because of this issue.

Avatar

Agreed. I had to make the same change to get it to work. Thanks!

Avatar

Hey!

Following the activemodel source code, the initialize method should check if the attributes isn't nil.

def initialize(attributes={})
  attributes.each do |name, value|
    self.public_send("#{name}=", value)
  end if attributes
end

Without it, I got errors running my specs

 NoMethodError:
   undefined method `each' for nil:NilClass
Avatar

I am also interested in this question.. in the first few steps of my multistep form I am working with user attributes, but in the next one I am working with user "interests" which is currently setup with a different model (related to the user using a HABTM)

Thanks! Awesome work!

Avatar

Your problem might be the same issue as mine. The object.send(association) doesn't seem to work for has_one relationships.

Anyone else have this issue or a solution?

Thanks

Avatar

How does one use queue_classic with rubber/capistrano? It seems like rake qc:work needs to run, just not sure where to put that command (in deploy.rb?) Thanks!

Avatar

How does this stack up Padrino? As far as performance and ease-of-use?

Avatar

I am using guard-rspec inside a vbox virtual machine (I cannot upgrade my Mac OS X 10.5.8 at this time, so this way I am developing on a virtual copy of the of the production OS, ubuntu 10).

Anyway it works great! But I would love to make use of guard-livereload.

Can anyone think of a way to have it both ways. IOW, running guard on the virtual machine and have it some how trigger livereload on my host MAc system?

Avatar

Hi Ryan,
Is it possible to add session variables as log tags to the log file or maybe some other way to add that info against each request?
I am migrating an app over from Rails 2.0 and only thing I can't get to work is adding session[:user_id] to the log output for each request.
Earlier it was done using monkey-patching ActionController's "log_processing" method.

Avatar

Turns out that the field expects the values to be an array and in a many to one the result is a string so I've amended the code to this in the form:

Rails
        = f.input :format_tokens, :input_html => { :data => { :load => [@book.format] } }

Which does list the entry properly, but even if I add another one, it will not save it. The resulting json list is in proper array format (I can see it with: http://localhost:3000/list_formats.json?q=hard), so I'm still missing something.

Thanks.

Avatar

I was able to create the relationship with a many to many, but with a many to one (where the book table has a corresponding ID for the format table for example) it doesn't work.

I can search but it will not save the values, nor will it prepolue the existing ones.

I'm sure I'm doing something wrong, but I pretty much copy/pasted the one for authors. Is there anything else that needs to change for this to work?

I don't get any javascript errors or warnings whatsoever.

Thanks.

Avatar

Please disregard, I was being an idiot and my method in book.rb had this

def author_tokens(tokens)

Instead of this:

def author_tokens=(tokens)
Avatar

What about we don't get user email from twitter, and I want user to specify it manually like you did with devise+omniauth in ep 236?

Avatar

Thanks Ryan, definitely a good idea to dive into internals.

Avatar

Thanks! Bootstrap datepicker worked well for me

Avatar

I tried this as well and I get the same error. I even tried this:

Rails
 f.input :author_tokens, :input_html => { "data-pre" => @book.author.collect{ |author| { :id => author.id } } }.to_json
Avatar

Hey Ryan, I'm new to Rails and this is exactly the type of thing I was working on doing a few days back :)

Primarily, because I learn by deconstructing, and I definitely, found too much noise + magic so far;

Please continue diving into Rails internals as this should be elucidated to the community as much as possible (it probably is I guess, but you also end up tremendously easing adoption by newcomers)

Thanks!

Avatar

This is as close as I've come to finding a good tutorial. I'm not skilled enough to reconcile the differences between that walk-through and this Railscast.

Have you found anything?

Avatar

Great episode! I would love to see a screencast on how to build a OAuth2 protected API with that ;)

Avatar

Hi. . . another great cast. . .
Any pointers to tutorials for using ipaddress with geocoder.
I've tried a few things but have not gotten it to work.
Many thanks

Avatar

How can I add a delete button column using the json/ajax approach? Here's what I'm trying to replicate:

ruby
<%= link_to 'Delete', product, method: :delete, class: "btn btn-mini btn-danger", confirm: "You sure?", title: product.product_number %>
Avatar

I like this episode a lot. Nevertheless, here's the inevatibable "but":

What first came into my mind when I was reading the headline was something like stripping down Rails itself into its components.

I see your point in trying to get to a minimal rails application. Yet, you would still have to install the full rails stack.

But would it also be possible to have a minmimal rails app running with only those modules installed, that are actually required by the application?

Where one might eventually end up with somthing like Sinatra for micro appslications?

Avatar

I'm having an issue. I have everything installed properly, in fact I even have the website up in localhost with a little bit of style to it. My issue is my admin panel doesnt look like that of which is in this video. For instance: Under those tabs body and side body, im missing that "tool bar" per-say. Where it gives the options of including h1 h2 tags, inserting images, html, et. Why is that?

Also when I click advanced options, nothing happens, also; I cant slide the top tabs the way I like them. Which seems fluid in this video. I'm using windows.

enclosed an image to see the lack of tool bar:
http://i50.tinypic.com/2zptemp.png

Avatar

I suppose ,it will not work on rails 3.2
Following worked on my enviroment.

1 add Gemfile and bundle

ruby
group :test do
  gem 'rspec-rails'
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem 'factory_girl_rails'
end

2 install them

bash
rails g rspec:install
rails g cucumber:install

rails g factory_girl:model YourModelName --dir=spec/factories

3 add features/support/env.rb

ruby
require 'factory_girl_rails'

4 make your *.feature and *_steps.rb file

Now cucumber dosnt use webrat but capybara . I cant find steps file for capybara. so you have to make steps.rb file by yourself,
referencing to https://github.com/jnicklas/capybara.

Avatar

Hey jDeppen thanks for posting this. Is this the only change you made? I tried it and am getting this error when starting Nginx:

error code
Restarting nginx: nginx: [emerg] host not found in upstream "unicorn" in /etc/nginx/sites-enabled/blog:21
nginx: configuration file /etc/nginx/nginx.conf test failed

I have 2 apps, blog and blog2. Followed Ryan's recipe verbatim with both apps, with one change (besides using blog2 in 2nd app). I have 2 domains propagated to my VPS and am using those as the server_name on line 7 of nginx.conf. I've been doing some Googling to see if there's anything I need to be doing with my hosts file, but no enlightenment.

Avatar

I know this thread is a bit old, but I was wondering if anyone has tried to pass the page param through a link to the show page.

Say I have a paginated list of users and I click on the show link for a particular user to see the info for that user, OK. HOWEVER, when I click the "Back" link it just does the index page from the start, instead of the "page" that it was on.

So, I am not sure how to go about passing the page param back and forth between the show page and the index page.

This seems like something most everyone would want?...

Avatar

Does anyone know how to add the new
to the results when token input can find something? I tried just doing

authors
authors << [{id: "<<<#{query}>>>", name: "New: \"#{query}\""}]

but for some reason that throws out an error. Firebug tells me the error is 'value undefined' and the token input drop down list disappears. I just don't get it. If the authors is empty it will return the new field just fine but if it finds any results it does not like the new added in.