Sha256: bef0aaef03f98d5decb175dae3d32e04e933706bbd26d36a82f3a73c7eeaff9b
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
= ripple-anaf This is inspired and similar implementation to the `accepts_nested_attributes` functionality found in AR. This allows the use update attributes and create new child records through the parent. It also allows the use of the `fields_for` form view helper, using a presenter pattern. To enable in the model, call the class method, using the same relationship as defined in the `one` or `many`. class Shipment include Ripple::Document property :identifier, String one :box many :addresses many :checkpoints accepts_nested_attributes_for :box, :addresses accepts_nested_attributes_for :checkpoints, :allow_destroy => true, :reject_if => proc{|attrs| attrs['signed_off'].blank? } end Now, you can do things like this: Shipment.create( :identifier => '1Z0001', :box_attributes => { :weight => 1.4 }, :addresses_attributes => [ { :street => "Main Street" } ] ) And in your views you can use fields_for: <%= form_for(@shipment) do |f| %> <%= f.text_field :identifier %> <%= f.fields_for :box do |ff| %> <%= ff.text_field :weight %> <% end %> <% end %> == Installation Currently in pre-release for testing. gem install ripple-anaf --pre == Supported Features * Same DSL for linked and embedded documents * :reject_if * :allow_destroy == Note on Patches/Pull Requests * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Send me a pull request. Bonus points for topic branches. == Copyright Copyright (c) 2010 Brian Kaney. See LICENSE for details.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ripple-anaf-0.8.0.beta2 | README.rdoc |