Turns your models into dynamic models, in a non traditional EAV style.
Normal EAV would have a values table, that looks like:
id entity_id attribute_id value_id
Acts as dynamics value table looks like this
id entity_id field_1 field_2 field_3 field_4 field_5
With a fields table that looks like
id name label bunchofoptions
The ID of this field, corresponds to column in value table, for that particular lookup. So its more of a matrix style EAV. Field columns are dynamically added to Fields table as they are created. (not yet)
## Scaffold Generator
The options are fairly verbose, I apologize in advance, I wanted to give the maximum amount of flexibility when working with this gem.
rails g dynamic_field_scaffold post use_fieldgroup_table:true create_fieldgroup_table:true fieldgroup_table_name:post_categories
Where “post” above, is the name of the entity you are creating the fields for. It should be an existing model in your app, this is the only model the generator won't create.
The command above should generate output similar to these files:
create db/migrate/20120416191442_create_post_fields.rb create db/migrate/20120416191443_create_post_field_values.rb create db/migrate/20120416191444_create_post_field_options.rb create db/migrate/20120416191445_create_post_categories.rb create app/models/post_field.rb create app/models/post_field_value.rb create app/models/post_field_option.rb create app/models/post_category.rb
Post category here is acting as the fieldgroup, scoping the available fields for a given post, by category. This allows you to have different sets of fields for different categories of entities. In order to utilize this behavior, you obviously need to first have a user choose a post category, when creating a post, so that they are then able to see the scoped fields.
Contributing to acts_as_dynamic
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
Fork the project.
Start a feature/bugfix branch.
Commit and push until you are happy with your contribution.
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2012 Jason Ayre. See LICENSE.txt for further details.