Note that there are some explanatory texts on larger screens.

plurals
  1. PORails nested resource on a singular resource form
    primarykey
    data
    text
    <p>I'm having a problem with Rails not POSTing anything in the params to an action. I'm using a singular resource with a nested plural resource which may or may not be where the problem is coming from (Rails has issues with form_for and singular resource URLs).</p> <p>Anyway, I have this in my routes:</p> <pre><code>resource :event do resources :actions, :only =&gt; [:create], :controller =&gt; "events/actions" end </code></pre> <p>The view:</p> <pre><code>&lt;%= form_for([@event, Action.new], :remote =&gt; true) do |f| %&gt; &lt;div class="field"&gt; &lt;%= f.label :team_id %&gt; &lt;br /&gt; &lt;%= f.text_field :team_id %&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :message %&gt; &lt;br /&gt; &lt;%= f.text_field :message %&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :score %&gt; &lt;br /&gt; &lt;%= f.number_field :score %&gt; &lt;/div&gt; &lt;br /&gt; &lt;%= f.submit "Update score" %&gt; or &lt;%= link_to "cancel", "#", :id =&gt; "cancel" %&gt; &lt;% end %&gt; </code></pre> <p>The create action:</p> <pre><code>def create @event = Event.find(params[:event_id]) @action = @event.actions.create(params[:action]) end </code></pre> <p>Ok pretty standard no worries there. But when I get the params from Rails nothing is there. :(</p> <p>Params:</p> <pre><code>Started POST "/event/actions.4e67f09349ae71090c00000e" Processing by Events::ActionsController#create as Parameters: {"utf8"=&gt;"Γ£ô", "authenticity_token"=&gt;"stuff", "commit"=&gt;"Update score"} Completed 500 Internal Server Error in 31ms </code></pre> <p>What is going on here?</p> <p><strong>Edit:</strong></p> <p>If I remove the ":remote => true" line in my view, I see that in my params I get one param ":format" which appears to be the ID of the event.</p> <p>However, I'm still not getting the action params. :(</p>
    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