Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Keil Miller Jr's Profile

GitHub User: keilmillerjr

Site: http://keilmiller.com

Comments by Keil Miller Jr

Avatar

You should not use the match method in your router without specifying an HTTP method.

Match is now depreciated with rails 4. I changed "match" to "get". I figured it makes sense to only support get in these routes. Who would be posting or patching in an unknown language?

ruby
# match '*path', to: redirect("/#{I18n.default_locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }
# match '', to: redirect("/#{I18n.default_locale}")

get '*path', to: redirect("/#{I18n.default_locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }
get '', to: redirect("/#{I18n.default_locale}")
Avatar

Thank you.

With Rails 4 depreciating Relation#update_all, your solution worked.

Avatar

Rails 4

DEPRECATION WARNING: Relation#update_all with conditions is deprecated. Please use Item.where(color: 'red').update_all(...) rather than Item.update_all(..., color: 'red').
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

Screencast is awesome.

I'm running into an issue: the sortable order gets messed up if the users page does not match the database. This can happen if they are using an outdated view (didn't refresh page) or another user changed the order before they refreshed the page. Any idea how to resolve this? Perform a check somehow to see if the data matches the db before the sort, else redirect.?

Avatar

ACTIVE MODEL CHANGES RAILS 3.1.1
http://weblog.rubyonrails.org/2011/10/7/ann-rails-3-1-1

Remove hard dependency on bcrypt-ruby to avoid make ActiveModel dependent on a binary library. You must add the gem explicitly to your Gemfile if you want use ActiveModel::SecurePassword:

ruby
gem 'bcrypt-ruby', '~> 3.0.0'

This might help others that might be staring at an Error page, wondering why that gem wasn't required. @rbates You should add it to the show notes. :)

Avatar

Also, don't forget that Rails.env is used instead of RAILS.ENV in rails 3!

Rails 3 do

ruby
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]

I also set up my config file with defaults that are loaded into each environment to keep things DRY.

ruby
defaults: &defaults

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults
Avatar

I followed this blog entry to load custom validators from lib/validators. I also named the EmailFormatValidator to EmailValidator. It makes more sense to me. :email => true. Great screencast as always, just needs the little update about loading validators. :)

Here's the snippet:

ruby
mkdir lib/validators

config/application.rb

ruby
config.autoload_paths += Dir["#{config.root}/lib/**/"]