SimpleForm can also be used with any
(such as created using ActiveAttr).
The only thing you have to keep in mind is to define
<attribute>_attributes= setter for the nested models.
This is only required for non-
ActiveRecord models where
accepts_nested_attributes_for is used instead.
See the Rails'
fields_for for more information.
It is also possible to "mix and match" different types of models (such as ActiveRecord and poor ActiveModel ones).
class ReservationFee < ActiveRecord::Base attr_accessor :credit_card # This is required by SimpleForm and Rails for non-ActiveRecord nested attributes def credit_card_attributes=(attributes) @credit_card = CreditCard.new(attributes) end end class CreditCard include ActiveAttr::Model attribute :number attribute :expiry attribute :cvn attribute :name end
Provided that you have it, SimpleForm can be used to generate Nested Models.
This page was created by the OSS community and might be outdated or incomplete. Feel free to improve or update this content according to the latest versions of SimpleForm and Rails to help the next developer who visits this wiki after you. So if you have a ScreenCast about SimpleForm or a blog post about something you did with the Wrappers API feel free to add it to the Resources page or write a new Guide.
Keep in mind to maintain the guides as simple as possible and to avoid additional dependencies that might be specific to your application or workflow (such as Haml, RSpec, Guard and similars).
Last edited by Lucas Mazza,