I have a ''new'' page with a submit for creating stories. On the ''show'' page the submit allows a user to enter comments. I now want a ''edit'' page for the stories with another submit for updates. I have used the ''create'' and ''update'' methods in the stories_controller on the ''new'' and ''show'' pages. What method can I use for the submit on the ''edit'' page? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 March 2010 20:33, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have a ''new'' page with a submit for creating stories. On the ''show'' > page the submit allows a user to enter comments. I now want a ''edit'' > page for the stories with another submit for updates. I have used the > ''create'' and ''update'' methods in the stories_controller on the ''new'' and > ''show'' pages. What method can I use for the submit on the ''edit'' page?Use update again. There is no problem calling the same action from two views. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You can also just add another public method to the controller. For instance, instead of using StoryController.update for updating the comments, you could use something like StoryController.add_comment. On Mar 5, 4:07 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 5 March 2010 20:33, Neil Bye <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > I have a ''new'' page with a submit for creating stories. On the ''show'' > > page the submit allows a user to enter comments. I now want a ''edit'' > > page for the stories with another submit for updates. I have used the > > ''create'' and ''update'' methods in the stories_controller on the ''new'' and > > ''show'' pages. What method can I use for the submit on the ''edit'' page? > > Use update again. There is no problem calling the same action from two views. > > Colin-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Paul Lynch wrote:> You can also just add another public method to the controller. For > instance, instead of using StoryController.update for updating the > comments, you could use something like StoryController.add_comment.How does the submit know which one to use? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Neil Bye wrote:> Paul Lynch wrote: >> You can also just add another public method to the controller. For >> instance, instead of using StoryController.update for updating the >> comments, you could use something like StoryController.add_comment.Googled loads, still can''t work it out? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 March 2010 13:49, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Paul Lynch wrote: >> You can also just add another public method to the controller. For >> instance, instead of using StoryController.update for updating the >> comments, you could use something like StoryController.add_comment. > > > How does the submit know which one to use?What do you mean? Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> >> How does the submit know which one to use? > > What do you mean? > > ColinI now want a ''edit''> page for the stories with another submit for updates. I have used the > ''create'' and ''update'' methods in the stories_controller on the ''new'' and > ''show'' pages. What method can I use for the submit on the ''edit'' page?So I have two submits and two method definitions. how can I make each submit relate to one of the differet methods. Neil -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 March 2010 12:13, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> >>> >>> How does the submit know which one to use? >> >> What do you mean? >> >> Colin > > I now want a ''edit'' >> page for the stories with another submit for updates. I have used the >> ''create'' and ''update'' methods in the stories_controller on the ''new'' and >> ''show'' pages. What method can I use for the submit on the ''edit'' page? > > > So I have two submits and two method definitions. how can I make each > submit relate to one of the differet methods.Do you mean you have two submits in one form? You had not mentioned that before, or I missed it. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote: .> > Do you mean you have two submits in one form? You had not mentioned > that before, or I missed it. > > ColinThere 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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Wrong attachment Attachments: http://www.ruby-forum.com/attachment/4563/stories_controller.rb -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 March 2010 12:44, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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.rbYou 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. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Neil Bye wrote:> I have a ''new'' page with a submit for creating stories. On the ''show'' > page the submit allows a user to enter comments. I now want a ''edit'' > page for the stories with another submit for updates. I have used the > ''create'' and ''update'' methods in the stories_controller on the ''new'' and > ''show'' pages. What method can I use for the submit on the ''edit'' page?you can have id for submit button then on form submission check the id of the submit button in javascript method and based on the submit mutton you can set the form action there and submit the form then. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Mar 10, 2010 at 8:22 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 10 March 2010 12:44, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> > You can specify the action in the form_for statement. >Thats all I wanted to know, but HOW ,I''m afraid I can''t yet understand anything more complex. Neil -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 March 2010 18:24, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > >> >> You can specify the action in the form_for statement. >> > Thats all I wanted to know, but HOW ,I''m afraid I can''t yet understand > anything more complex.I suggest you start by looking at the docs for form_for. If you look at http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html (which was the first hit googling for form_for) you will find the first example shows how to use the url option to specify an action. Also have a look at the rails guides at http://guides.rubyonrails.org/. Start with Getting Started, work through them writing and trying out the code yourself. When you get to the one on Action View Form Helpers you will find another example on how to use the url option of form_for to specify an action. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 10 March 2010 18:24, Neil Bye <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I suggest you start by looking at the docs for form_for. If you look > at http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > (which was the first hit googling for form_for) you will find the > first example shows how to use the url option to specify an action. > > Also have a look at the rails guides at > http://guides.rubyonrails.org/. Start with Getting Started, work > through them writing and trying out the code yourself. When you get > to the one on Action View Form Helpers you will find another example > on how to use the url option of form_for to specify an action. > > ColinThanks very useful links. Will keep me busy. Neil -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.