Hi, I wanted to create some static pages using rails and used rails g controller Staticpages main movie song book Which has created a controller file "static_pages_controller.erb" and view files under /views/static_pages/main.html.erb etc I have created a form using form_for on my main page which has a drop down menu for selecting one of "movie, song, book" and a submit button using <%= form_for :mode do |f| %> <div class="field"> <%= f.label :mode %><br /> <%= f.select :mode, [''Please select one'', ''Movie'', ''Book'', ''Song''] %> </div> <div class="actions"> <%= f.submit "Submit" %> </div> <% end %> My controller file looks like this class StaticPagesController < ApplicationController def main end def movie end ... end A click on submit on my main page generates ''No route matches POST "/static_pages/main" . Do i have to create a func for post? If so since the static pages class is same for the remaining movie,book, song how do i handle submits from other pages? Also how do i retrieve the values of form_for in the controller? -- 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.
routes.rb have only these get "staticpages/main" get "staticpages/movie" get "staticpages/book" How do i add a route to post method? -- 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.
Check http://guides.rubyonrails.org/routing.html You''ll find everything you need to understand how to configure your routes. Le 22 juin 2012 21:24, "cyber c." <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> a écrit :> routes.rb have only these > > get "staticpages/main" > get "staticpages/movie" > get "staticpages/book" > > How do i add a route to post method? > > -- > 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. > >-- 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.
Sorry didn''t finished my previous message I''m on my phone. First of all, read http://guides.rubyonrails.org/getting_started.html You''ll understand how to start and you''ll understand what you need to do in your controller and your routes.rb. Le 22 juin 2012 23:05, "Arnaud Augier" <arnaud.augier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> a écrit :> Check http://guides.rubyonrails.org/routing.html > > You''ll find everything you need to understand how to configure your routes. > Le 22 juin 2012 21:24, "cyber c." <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> a écrit : > >> routes.rb have only these >> >> get "staticpages/main" >> get "staticpages/movie" >> get "staticpages/book" >> >> How do i add a route to post method? >> >> -- >> 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. >> >>-- 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.
I can specify the controller using :url => {:action => ''XYZ''} But since I don''t have ( nor need) a model file for the form , so what should i write here "?" <%= form_for (?) do |f| %> -- 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.
u need to do this form_for(:mode, :url => {:action => "action_name", :controller => "controller_name"}) and in the routes file, u need to add post "static_pages/main" "contoller_name#action_name" On Sat, Jun 23, 2012 at 4:32 AM, cyber c. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I can specify the controller using > :url => {:action => ''XYZ''} > But since I don''t have ( nor need) a model file for the form , so what > should i write here "?" > <%= form_for (?) do |f| %> > > -- > 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. > >-- Thanks, Aash -- 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 23 June 2012 00:02, cyber c. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I can specify the controller using > :url => {:action => ''XYZ''} > But since I don''t have ( nor need) a model file for the form , so what > should i write here "?" > <%= form_for (?) do |f| %>If you have not got an object to populate the form then you can use form_tag instead. 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.