RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Don't know if this will help you, but what fixed it for us was specifying a specific version of the devise gem.

in our gemfile:

gem 'devise', '~> 3.0.1'

Avatar

AT 10:48 when you change the sticky of a topic to NOT be sticky, it doesn't change the status from sticky to non.

Avatar

same here, Ryan, do you think the video can be fixed somehow?

Avatar

I'm getting the same error Jonathan E. Emmett is getting. Three other developers, running (virtually) identical systems do NOT get the error. I have tracked it down (I think) to the fact that 'stringify_keys' is getting an array instead of a hash, but why is that happening? I'm running Ruby v. 1.9.3p392 Rails v. 4.0.0.

Avatar

+1 and thanks for this- (i know this is old, but think this fix is important and deserves a little more amplification)....

this version has the quotation fix for two word menu entries and initializes properly with the trigger "change"

Avatar

Following the screencast, but using 'head' instead of the commit used in the screencast, I get this:

command line
$ rake mercury_engine:install:migrations
rake aborted!
Don't know how to build task 'mercury_engine:install:migrations'

(See full trace by running task with --trace)

Any suggestions on how to install the migrations?

Avatar

Can't you do an if statement? If your width if larger than height, X, else, Y. Shouldn't be hard.....

Avatar

There's an updated gem for Rails 4 here.

Avatar

Ok forget this comment. I'm an idiot. I was trying to load faye.js from localhost. Didn't update the application layout with prod location of faye.js. doh!

Avatar

Ryan,

It appears this screencast is no longer playing. In Chrome, it says "Can't play video. Media source loading has failed." It won't play in Safari, either, though no error is displayed.

I'm not having trouble with any of the other screencasts, just this one.

Avatar

did you find and answer for that? I'm also trying to find a good solution for this problem

Avatar

@bakki, did you find and answer for that? I'm also trying to find a good solution for this problem

Avatar

this is as useful as tits on a bull, its dated and from the comments above doesn't seem to be working

Avatar

What is {%=o.name%} ? I'm having issues on how to write it using Slim.

By the way, since I'm a noob, I found using gem 's3_direct_upload' to be very helpful. (THANK YOU!) https://github.com/WayneHoover/s3_direct_upload

But overall, I am getting the feeling that this solution isn't yet dependable for production apps because of browser compatibility and reading comments seems like there are many other bugs. So, in that case, is it better for me to use an external service i.e. inkfilepicker.com ? Other than $, are there any other cons of doing this?

Avatar

Use rails g devise:views to generate the views

Avatar

I know this sounds stupid by why not add a class and forget the js.

ruby
class ="#{current_user.is_admin? ? "" : "hide"}"
Avatar

To avoid having test:prepare run each time, you can further drop this into Rakefile:

ruby
Rake.application.instance_eval do
  # Remove test:prepare
  @tasks['test:benchmark'].prerequisites.shift
  @tasks['test:profile'].prerequisites.shift
end
Avatar

I have an issue with several has many throughs connecting the same models. As an example Book and Person connected through Reader and Writer. How does my equivalent of "author_tokens" setter method distinguish which one to save?
I have made reader_tokens and writer_tokens methods, but when they do
self.person_ids = Person.ids_from_token(tokens) I can't name the relationship (reader or writer). Should I move my method to the relationship models, or how can I modify them, so they work?

Avatar

Thanks! This worked for me too. but after the first time it stopped working. I am using rails4. Any ideas?

Avatar

I want to know if someone do some angular unit test with karma or something else ?

It hard to find something on the web when i use 'rails coffeescript angular test'
i found almost nothing ...

Avatar

I have a VPS on digital ocean and I've been meaning to deploy a rails app to it. I have never done any server configuration before. Where can I read up on it?

Avatar

Hi,
How can I format the index.xls.erb so that the xls which is exported has columns with different width and :word-wrap: normal ?
Thanks,
christina2013

Avatar

Thanks a lot for that.

Avatar

I build a web app using faye. Works great, but then I tried to access my site on android chrome and nothing. None of the js is getting executed on my android devices. Anyone know a fix? I tried to google and didn't have much luck.

If not getting the publishing to work on android, anyone got any ideas for fallback methods so at least the client initiating the change receives updates outside of faye?

Avatar

This can happen using DRB gems like Spork and Zeus

Avatar

It's best to just browse the gem's github repo for changes. I organize my files a little differently than default, so I don't want those changes over ride.

Avatar

Well the problem, weirdly, was i hid the pagination class in my css because I wasn't able to get the pagination links to disappear and replace with the text "Fetching more products"...so now it works fine but the pagination is still showing at the bottom of the page before the next page gets loaded

Avatar

For some reason some of my posts are getting duplicated when the next page of posts are getting loaded. Has anyone had this happen to them??

Avatar

bump :)
did someone found alternative for rails 4 and client side validation ?

Avatar

Just ran into this myself. Should've read the comments before I plunged into the StrongParameters docs. Oh well.

Avatar

Calling @comment.create_activity :destroy, owner: current_user after if @comment.destroy gives the following error: You cannot call create unless the parent is saved.

Any ideas?

Avatar

+1 but I still cant make my search find any row when I search for "Police" writing only "polic". I have to write the full word exactly how it is. Any help?

Avatar

Need help, i get this error in console when i create new record withe hstore data?

ActiveRecord::StatementInvalid: PG::InternalError: ERROR: Syntax error near ':'

Avatar

hi there, I had some problems with factory_girl, actual versions syntax is a bit different (Link). This factories.rb accomplished the same job (as in the screencast):

ruby
FactoryGirl.define do
  sequence :email do |n|
    "email#{n}@factory.com"
  end
  factory :user do
    email
    password "secret"
    password_confirmation "secret"
  end
end

you can create a user in your specs with:

ruby
user = FactoryGirl.create :user

I'm also using database_cleaner to get my db into a clean state for the tests (Link), because some of the changes to the database weren't rolled back after the tests when using factory_girl and I got failures in further test-runs (I needed version 1.0.1, because 1.1.1 generates a bug if using sqlite-db Link).
Adding this line to my Gemfile under the test group definition does the fix:

ruby
gem "database_cleaner", '1.0.1'

Database_cleaner is quite easy to setup and seems to work pretty neat.

Maybe someone runs into the same problems, it took me quite a bit of googling to get everything together with the current sw-versions, so I thought I'd post it here. Cheers!

Avatar

Great Episode. I really enjoyed it.

Avatar

Full of information for upgrading!

Is there any reason for putting the following line in config/environments/development.rb by default?

=# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

The rails app is going to throw out mass_assignment error if a protected attribute is submitted on a form. I can not think of a good reason for doing that by default in development.

Avatar

How do you add a :selected to the grouped_collection_select ???

Avatar

Great tutorial. I couldn't get it to work until I changed line 4 in products.js.coffee from

url = $('.pagination .next_page').attr('href')

to

url = $('.pagination .next_page a').attr('href')

otherwise it doesn't pull the href attribute from the link.
Thanks for the tutorial!

Avatar

Actually, furthermore you really should be adding a to_s on @foo:

var foo = '<%= j @foo.to_s.html_safe %>';

Because if there's any chance @foo might not be a string, you'll get a NoMethodError trying to call html_safe on it.

I'm gonna go out on a limb here and wager that most Rails devs are not applying these three (count 'em, three) conversions on their values in order to splat them into a script?

Avatar

It seems to me this railscast is presenting the incorrect way to put content into javascript variables.

If you are trying to put a template variable into a javascript variable inside an HTML template, the syntax is actually not very intuitive:

var foo = '<%= j @foo.html_safe %>';

You have to flag the string as safe for raw output into the html document, but also apply javascript escaping. Otherwise, if @foo contains "<foo>" then your final document output will be:

var foo = '&lt;foo&gt;';

Which is almost certainly not what you want.

However, if you use html_safe but forget to apply the javascript escaping, you are opening yourself seriously to javascript injection attacks. So this is stuff that must be done very carefully in order to be done both correctly and safely.

IMO it is unfortunate that apparently no authoritative documentation or respected tutorials point this nuance out, and that Rails has no better, more intuitive way to put content safely and correctly into javascript strings...

Avatar

I'd like to know this as well. It's not clear without diving into the source whether there will be serious issues if the copycopter server goes down.

Avatar

Yes, this is a database problem, not a thread problem.

Avatar

Hi Ryan, another great railscast from you, congrats!

I'm looking for something similar, but on this case you need to select what you want to edit and then do it one by one... How can I edit them directly on the first screen, without having to go to another screen?

I would filter all the fields, for example, fields that aren't approved yet (being "approved" a boolean), and when I get that list of unapproved items, I would have the chance to edit all them at once!

Is this possible? Anyone has done this?

Avatar

AFAIK Foundatiom overwrites style for table tags.

Avatar

Cheers mate. It was really helpful ;)