Hi, I''m new in RoR, I need some help in the following situation: I have 2 controllers, clinica and consultas. Clinica is my default controller. On /views/clinica, I have the index.html.erb default of my aplication, and I have there the command: <%= button_to "Read More", new_consulta_path, :class=>"icon icon-arrow-right button", %> on the routes.rb I have: Clinica::Application.routes.draw do resources :clinica resources :consultas on /views/consultas/new.html.erb I have a form, if I write the URL "http://localhost:3000/consultas/new" I get the form without problems. The problem here is that when I click on the button "Read More" (on the index default of my application on Clinica) I get the error "No route matches [POST] "/consultas/new"". I can''t understand what is the mistake I''m doing. Does anyone know what is happening? Any help is welcome! Thank you, Rita Ferreira -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cc1132a8-aae5-433c-be99-7ad22da91a7d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Friday, August 23, 2013 12:25:29 PM UTC+1, Rita Ferreira wrote: on the routes.rb I have:> > Clinica::Application.routes.draw do > > resources :clinica > > resources :consultas > > > on /views/consultas/new.html.erb I have a form, if I write the URL " > http://localhost:3000/consultas/new" I get the form without problems. > > The problem here is that when I click on the button "Read More" (on the > index default of my application on Clinica) I get the error "No route > matches [POST] "/consultas/new"". I can''t understand what is the mistake > I''m doing. >button_to does a post request by default. if you add a :method => :get option to it then it should work Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7155dae6-0054-49f4-9889-950ee9786134%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Aug 23, 2013, at 6:25 AM, Rita Ferreira <ritaferreira83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I''m new in RoR, I need some help in the following situation:Hi, Rita, welcome!> > I have 2 controllers, clinica and consultas. > Clinica is my default controller. > > On /views/clinica, I have the index.html.erb default of my aplication, and I have there the command: > > <%= button_to "Read More", new_consulta_path, :class=>"icon icon-arrow-right button", %>The issue here is that button_to automatically generates a form with a submit button. The default method for forms in "POST" (which is why you''re seeing that in the routing error below. Take a look at the page source for this view to see what is being generated. The docs for button_to are at: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to You can change the method used by passing in the :method => :get option on that call. The other thing you might look at is using link_to instead of button_to, and making it look like a button with css classes. (It looks like you''re using twitter bootstrap, which does this pretty easily.)> > on the routes.rb I have: > > Clinica::Application.routes.draw do > > resources :clinica > > resources :consultas > > > on /views/consultas/new.html.erb I have a form, if I write the URL "http://localhost:3000/consultas/new" I get the form without problems. > > The problem here is that when I click on the button "Read More" (on the index default of my application on Clinica) I get the error "No route matches [POST] "/consultas/new"". I can''t understand what is the mistake I''m doing. > > Does anyone know what is happening? > Any help is welcome! > Thank you, > Rita Ferreira > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cc1132a8-aae5-433c-be99-7ad22da91a7d%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/17B86AEC-6812-46F6-8D97-13A6C412A676%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi Fred, Thanks a lot, it worked :) Sexta-feira, 23 de Agosto de 2013 18:48:28 UTC+1, Frederick Cheung escreveu:> > > > On Friday, August 23, 2013 12:25:29 PM UTC+1, Rita Ferreira wrote: > on the routes.rb I have: >> >> Clinica::Application.routes.draw do >> >> resources :clinica >> >> resources :consultas >> >> >> on /views/consultas/new.html.erb I have a form, if I write the URL " >> http://localhost:3000/consultas/new" I get the form without problems. >> >> The problem here is that when I click on the button "Read More" (on the >> index default of my application on Clinica) I get the error "No route >> matches [POST] "/consultas/new"". I can''t understand what is the mistake >> I''m doing. >> > > button_to does a post request by default. if you add a :method => :get > option to it then it should work > > Fred >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4725a220-bf7c-49b6-938f-6c405ed6a8c1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi tamouse, I tried it with button_to with the ''tag'' :method => :get and I got no error! Then I decided to use link_to and I got success too! Thank you veryyyy much :) Sexta-feira, 23 de Agosto de 2013 19:17:40 UTC+1, tamouse escreveu:> > > On Aug 23, 2013, at 6:25 AM, Rita Ferreira <ritafer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<javascript:>> > wrote: > > > Hi, > > I''m new in RoR, I need some help in the following situation: > > Hi, Rita, welcome! > > > > > I have 2 controllers, clinica and consultas. > > Clinica is my default controller. > > > > On /views/clinica, I have the index.html.erb default of my aplication, > and I have there the command: > > > > <%= button_to "Read More", new_consulta_path, :class=>"icon > icon-arrow-right button", %> > > The issue here is that button_to automatically generates a form with a > submit button. The default method for forms in "POST" (which is why you''re > seeing that in the routing error below. > > Take a look at the page source for this view to see what is being > generated. > > The docs for button_to are at: > http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to > > You can change the method used by passing in the :method => :get option on > that call. The other thing you might look at is using link_to instead of > button_to, and making it look like a button with css classes. (It looks > like you''re using twitter bootstrap, which does this pretty easily.) > > > > > > on the routes.rb I have: > > > > Clinica::Application.routes.draw do > > > > resources :clinica > > > > resources :consultas > > > > > > on /views/consultas/new.html.erb I have a form, if I write the URL " > http://localhost:3000/consultas/new" I get the form without problems. > > > > The problem here is that when I click on the button "Read More" (on the > index default of my application on Clinica) I get the error "No route > matches [POST] "/consultas/new"". I can''t understand what is the mistake > I''m doing. > > > > Does anyone know what is happening? > > Any help is welcome! > > Thank you, > > Rita Ferreira > > > > -- > > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > > To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:>. > > > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/cc1132a8-aae5-433c-be99-7ad22da91a7d%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/eea9fd8c-7514-4c13-a674-f1dff24ad1b4%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.