I have two models
class Redemption < ActiveRecord::Base
has_many :redemption_status_notes
accepts_nested_attributes_for :redemption_status_notes
...
end
and
class RedemptionStatusNotes < ActiveRecord::Base
belongs_to :redemption
belongs_to :admin
attr_accessible :notes, :status
end
Using simple_for I am trying to create a form to edit the first model, with a single field that if populated will create a new record of RedemptionStatusNotes when the form is saved with the text of that field, the id of the Redemption that is being worked on, and the id of the currently logged in admin (we use devise so it's just current_admin.id)
current state of the form looks like this
= simple_form_for resource, url: form_url, html: {class: "validate"} do |f|
...
.row-fluid
.span4
= f.input :admin_id, as: :select, collection: Admin.all, value_method: :id, label_method: :email, label: "Owner", placeholder: "Unassigned", input_html: {style:"width:98%"}
= f.input :status, as: :select, collection: Redemption.statuses_for_select, input_html: {style:"width:98%"}
- f.simple_fields_for :redemption_status_note do |note|
= f.input :notes, as: :text
= f.input :price, input_html: {style:"width:98%"}
...
The rest of the form is rendering and updating fine, but I can't even get the notes field to show up. Is it even possible to nest a "create" form inside an "edit" form?
I have so far tried following the documentation for creating forms with nested models here as well as this SO question and a few others I no longer have the url too.
Aucun commentaire:
Enregistrer un commentaire