Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

nodrog's Profile

GitHub User: nodrog

Comments by

Avatar

@rosobas pointed this out but as people are still having issues, this is what the initializer should look work with rails 3.1 >

ruby
class ActiveRecord::Base
  attr_accessible
  attr_accessor :accessible
  
  private
  
  def mass_assignment_authorizer(role = :default)
    if accessible == :all
      self.class.protected_attributes
    else
      super + (accessible || [])
    end
  end
end

mass_assignment_authorizer now takes a role parameter...

Avatar

This is a massive complement to Ryan, but his tutorials really are the simplest to describe the functionality that he is trying to implement in the most elegant way. If you need more dumbed down perhaps you should a: not implement the feature, or do it in a less elegant way with before_save functions on particular attributes (which would work in most cases).

Avatar

humm, not sure about default, what if just choose one!

Avatar

Just a quick note for anyone using mongomapper or mongoid, or anything that requires removing active record but removing the line

ruby
require 'rails/all'

make sure you add:

ruby
require 'sprockets/railtie'

this is not currently documented