Note that there are some explanatory texts on larger screens.

plurals
  1. PORails fields_for won't see my field inside
    primarykey
    data
    text
    <p>I am trying to create two object at the same time. The best approach I have is to used fields_for. and the relationship is has_many.</p> <p>model/location.rb</p> <pre><code> attr_accessible :address, :customer_id, :event_id, :latitude, :longitude belongs_to :customer belongs_to :event </code></pre> <p>model/event.rb</p> <pre><code> attr_accessible :locations_attributes has_many :locations, :dependent =&gt; :destroy accepts_nested_attributes_for :locations </code></pre> <p>The form is has follow:</p> <pre><code>&lt;%= form_for(@event) do |f| %&gt; ... &lt;%= f.fields_for :locations do |e| %&gt; &lt;%= e.text_field :longitude %&gt; &lt;%= e.text_field :latitude %&gt; &lt;% end %&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>My fields won't show up, I have followed the documentation has_many from this section <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for" rel="nofollow">http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-fields_for</a> and notice if in my f.fields_for :locations change it to singular than the fields will show up but i won't be able to create it because i am not allow to modify the locations_attributes.</p> <p>UPDATE:</p> <p>If i singular it. I change this to my event model</p> <pre><code> attr_accessible :description, :title, :location_attributes </code></pre> <p>The error is like this</p> <pre><code>app/controllers/events_controller.rb:60:in `new' app/controllers/events_controller.rb:60:in `create' </code></pre> <p>My controller is like this</p> <pre><code>line 60: @event = Event.new(params[:event]) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload