On Wed, Mar 10, 2010 at 8:22 AM, Colin Law <clan...@googlemail.com> wrote:
> On 10 March 2010 12:44, Neil Bye <li...@ruby-forum.com> wrote:
>> Colin Law wrote:
>> .
>>>
>>> Do you mean you have two submits in one form?  You had not mentioned
>>> that before, or I missed it.
>>>
>>> Colin
>> There are three separate forms on three pages but they all refer to the
>> stories_controller.rb . In the controller I a 'create' method  for the
>> 'new' page
>> The 'update' method  is for comments submitted on the 'show' page. Now I
>> want an 'edit' page with a submit. What method can I use and how does
>> the submit on the edit page know how to use it.
>>
>> Attachments:
>> http://www.ruby-forum.com/attachment/4562/stories_controller.rb
>
> You can specify the action in the form_for statement.
>
> However, as I suggested earlier I would not use a separate action
> anyway.  If you look at your code for update and add_comment you will
> see there is a lot of similarity.  I would combine add_comment into
> update and test params[:comment] to see whether to add the comment or
> not.

A more conventional approach here might be to treat comments as nested
resources, and have a Comments controller.

http://railscasts.com/episodes/139-nested-resources

And if you substitute Story for Article in Ryan's example app in the
railscast, it would appear to pretty much be the OPs problem.
-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to