Skip to content

Rails Plugin for friendlier mass assignment (because attr_protected is the suck)

License

Notifications You must be signed in to change notification settings

jcnetdev/acts_as_applyable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActsAsApplyable
===============

acts_as_applyable is a Rails plugin that allows you to ditch attr_accessible and attr_protected, in favor of a cleaner way of dealing with mass assignment

Example
=======

Old way:
@user = User.new(params[:user])
@user.save

New way:
@user = User.new
@user.params = params[:user]
@user.apply(:username, :email, :password, :password_confirmation)

In order to enable it, run this on your model

If you want to act similar to attr_accessible, you can define a method called applyable_attributes that returns
the array of fields you want to appy by default.

def applyable_fields
 [:name, :email, :password]
end

that way you can run @user.apply and it will use these

Copyright (c) 2008 RailsJedi.com, released under the MIT license

About

Rails Plugin for friendlier mass assignment (because attr_protected is the suck)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages