acts-as-savable extends an ActiveRecord model so that it can read from a view, and save to a table.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install acts-as-savable
Given tables named "things" and "thing_decorations", and a view named
"decorated_things" that joins on the other two, you can declare a
DecoratedThing class like this:
class DecoratedThing < ActiveRecord::Base saves_to :thing_decorations, :thing_id, :decoration end
All the finders work as expected, but
update_attributes! all create and/or update records
in the "thing_decorations" table (in this case updating ony the
This was extracted from an app, and is constrained by assumptions related to that app. It is very naive and not likely to solve all of your problems. If you have a problem that this almost solves, but not quite, please file an issue at https://github.com/dchelimsky/acts-as-savable/issues and help me to make it more useful for a wider audience.