I’ve ignored the course recommendation to use Rails 1.9.3 and Rails 3.2.12. I also tend to use the latest versions of other gems, though I’m pretty quick to dial back a gem if I find an incompatibility. I do maintain a “course standard” environment to test against so I don’t misuse thoughtbot resources with these practices.
I’ll document changes I run into. Please add any you find too. Make sure to include relevant version numbers and links to docs if you can. If appropriate, note which class video and approximate time.
As of Rails 4, the generated migration for a belongs_to now includes the index on the column declaration line.
rails generate model shout body user:belongs_to
class CreateShouts < ActiveRecord::Migration
def change
create_table :shouts do |t|
t.string :body
t.belongs_to :user, index: true
t.timestamps
end
end
end
The Rails 3 way adds a separate statement after the create_table:
The statement above is added to handle Timeline’s need for the to_partial_path method.
The to_partial_path method in Rails 4 is now located in ActiveModel::Conversion. I followed the example in the doc and used include rather than extend.
I checked earlier docs, and it looks like to_partial_path has been in ActiveModel::Conversion since Rails 3.2.1. So this is not really a Rails 4 change. Perhaps it is an error in the video? I’m not sure how @halogenandtoast got to_partial_path to work via ActiveModel::Naming.
As Matt mentions, that syntax (with the block) is Rails 4 compatible. If you omit the block, you’ll get a deprecation warning in Rails 4.
Rails 4 also allows passing a hash to order:
default_scope { order(created_at: :desc) }
It’s worth noting that while a block is enough for default_scope, the Rails 4 scope method requires a callable object. You may also use the a callable object for default_scope.
Sorry to bump up such an old thread, but I was curious what happened to making updated versions or if you see Upcase updating some of the course material in the near future? Even though some some of the videos are a little outdated they’ve definitely been some of the best tutorials I’ve watched and would love to see everyone benefit from your excellent teaching style.
Edit: ^I feel like I wrote that prematurely, as the videos really do not have much you need to change for rails 4. I also kind of enjoyed having to poke around deeper to figure out the changes.
It’s on our list, but at a somewhat lower priority than other things.
As you said, almost all the information is still valid and good, so the (quite large) effort of updating for a new version needs to be weighed carefully.