Of course use good old ruby’s attr_accessor
. In your model:
attr_accessor :foo, :bar
You’ll be able to do:
object.foo = 'baz'
object.foo #=> 'baz'
More Related Contents:
- Is there a way to get a collection of all the Models in your Rails app?
- Case-insensitive search in Rails model
- How to do a LIKE query in Arel and Rails?
- Rails model without database
- ActiveRecord OR query Hash notation
- ActiveRecord, has_many :through, and Polymorphic Associations
- Using Rails serialize to save hash to database
- Rails 3: Get Random Record
- Rails: select unique values from a column
- Setting session timeout in Rails 3
- How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'”
- Clean way to find ActiveRecord objects by id in the order specified
- Rails find_or_create_by more than one attribute?
- Overriding id on create in ActiveRecord
- How do i work with two different databases in rails with active records?
- Rails ActiveRecord: Find All Users Except Current User
- Rails 3 – select with Include?
- GroupingError: ERROR: column must appear in the GROUP BY clause or be used in an aggregate function
- belongs_to through associations
- Check if record exists from controller in Rails
- Rails 4 nested attributes and has_many :through associaton in a form
- rails dates with json
- delete_all vs destroy_all?
- ActiveRecord serialize using JSON instead of YAML
- How to implement Active Record inheritance in Ruby on Rails?
- Store the day of the week and time?
- Is there a way to avoid automatically updating Rails timestamp fields?
- Rails gem rails3-jquery-autocomplete: How do I query multiple fields
- Rails best way to get previous and next active record object
- Rails Object Relationships and JSON Rendering