Skip to content

codyrobbins/save-changes-to

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Save Changes To

This Rails plugin makes a save_changes_to method available in ApplicationController which takes the name of an ActiveRecord model and updates the attributes of an instance of that model an appropriately named instance variable in the controller with the attributes in params corresponding to the model name.

Full documentation is at RubyDoc.info.

Example

The following

class UserController < ApplicationController
  def update
    save_changes_to(:user)
  end
end

is the equivalent of

class UserController < ApplicationController
  def update
    @user.update_attributes(params[:user])
  end
end

Colophon

See also

If you like this gem, you may also want to check out Declarative Find, Create New, or HTTP Error.

Tested with

  • Rails 3.0.5 — 20 May 2011

Contributing

To send patches, please fork on GitHub and submit a pull request.

Credits

© 2011 Cody Robbins. See LICENSE for details.

About

Save changes to Rails models from params in one call.

Resources

License

Stars

Watchers

Forks

Languages