method

attributes=

Importance_1
v3.2.8 - Show latest stable - 0 notes - Class: AttributeAssignment
attributes=(new_attributes) public

Allows you to set all the attributes at once by passing in a hash with keys matching the attribute names (which again matches the column names).

If any attributes are protected by either attr_protected or attr_accessible then only settable attributes will be assigned.

class User < ActiveRecord::Base
  attr_protected :is_admin
end

user = User.new
user.attributes = { :username => 'Phusion', :is_admin => true }
user.username   # => "Phusion"
user.is_admin?  # => false
Show source
Register or log in to add new notes.