ruby on rails - Putting create action for one model in show page of another -


I asked before and the way I should be

I have a simple app that has three The tables are users, robots, and recipients are members of robots and the recipients belong to robots.

On the robot show page, I want to be able to create recipients for that robot inside the robot show page.

I have the following code in robot show page that lists present recipients:

   & Lt; B & gt; & Lt;% = h Recipient.watch_skrine_name% & gt; & Lt; / B & gt; By & lt;% = h Recipient.prologic_name & lt; / Td> & Lt; Td> & Lt;% = link_to 'edit', edit_recipient_path (recipient)%> & Amp; Nbsp; & Lt; / Td> & Lt; Td> & Lt;% = link_to 'Delete', recipient ,: confirmation = & gt; 'Are you sure?' ,: method = & gt; :% & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt;% end% & gt; & Lt; / Table & gt;  

And now I have this robot in the show view:

  <% form_for (rerecipient) do | F | & Gt%; Enter screen name & lt; Br> & Lt;% = f.text_field: chat_screen_name% & gt; & Lt; P & gt; & Lt;% = f.submit 'Update'% & gt; & Lt; / P & gt; & Lt;% end% & gt;  

and the robot controller has also added this:

  @recipient = recipient.new @recipients = recipient.All  

Now I see the field I want to see, but it seems that the recipient is still not connected to the robot which is showing the page is the page. Also, when I have this code, in front of the robot show page, the redirect recipient on the creation is going to the recipient page.

I have this code in the Viewer Controller in Implementation:

  def create  

I really appreciate any additional help I know that I am close to the solution, but not quite .... .... < / P>

Thank you.

  @recipient = recipient.new (param [: recipient])  < / Pre> 

This creates a new recipient on the basis of the submission form, but there is nothing in it to nominate the robot you want to use because there is no parameter [: Recipient] [: robot_id], no Can not be a @ recipient. Robot.

Either try nested resources and access the robot ID from the URL parameter, or access the hidden field with robot ID and access it from the submitted form.

The main point is here: Param [[Recipient] is included only in the form that has been passed from the form, and you are not able to find any Robot ID anywhere. / P>


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -