public
Description: Rails authentication with email & password.
Home | Edit | New

attr_accessible

User model uses attr_accessible. This is a best practice and Clearance is opinionated about it.

If you have any other attributes in your User, you will need to use attr_accessible on them, otherwise, they will not set during mass assignment. For example, if your model also has a ‘name’:

class User < ActiveRecord::Base
   include Clearance::User
end

class UsersController < Clearance::UsersController
  def create
    @user = Users.new(params[:user]) # what the?!? why isn't name getting set?
    # ... snip
  end 
end

To fix, just add the appropriate calls to attr_accessible:

class User < ActiveRecord::Base
   include Clearance::User
  attr_accessible :name
end
Last edited by dancroak, Tue Apr 21 18:19:57 -0700 2009
Home | Edit | New
Versions: