Okay, some elucidation:

The following works when report.new_record? is true, fails when 
report.new_record? is false:


form_for([...@user, report])
  ...

because it's trying to call the undefined function 'user_report_path'. 
(Of course it's undefined -- I've specified shallow routing!)  So 
perhaps @Alex's comment of http://www.ruby-forum.com/topic/206593 is 
relevant here.

So if I modify my form_for for the new_record vs non-new_record, it 
looks like this (yech):

<% form_for((report.new_record?)?([...@user, report]):(report)) do |f| %>
  <%= f.submit 'JumpUpAndDown' %>
<% end %>

Aside from looking pretty nasty, the generated HTML is a bit suspicious: 
Shouldn't it be a POST method when report.new_record? is true and a PUT 
method when report.new_record? is false?

Generated for report.new_record? == true:

<form action="/users/29/reports" class="new_report" id="new_report" 
method="post">
<input id="report_submit" name="commit" type="submit" 
value="JumpUpAndDown" />
</form>

Generated for report.new_record? == false:

<form action="/reports/79" class="edit_report" id="edit_report_79" 
method="post">
<input id="report_submit" name="commit" type="submit" 
value="JumpUpAndDown" />
</form>

What am I missing here?

- ff
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to