Rails 3: I have a view books/:id/show.html.erb - in the view, I have a form with a select tag to pick a template, that on dropdown should submit the form which rerenders the page based on the selection: <%= form_tag book_path(@book) do %>> > <%= select_tag "template[]", >> options_for_select([["Template1","template1"], ["Template2", "template2"]]), >> :value => (@template || ''template1''), :onchange => ''this.form.submit();'' %> > > <%end%> > >In my controller, I have> @template = params[:template] || ''post''In my routes, I have resources :books, :only => [:show] and rake routes indeed shows book GET /books/:id(.:format)> {:controller=>"books", :action=>"show"}When I first navigate to this view, it all works fine and the view renders as expected. If I select a different template from the dropdown, I get the error: No route matches ''books/1'' The funny thing is that the current page is exactly that route. If I refresh the page, it renders with the default template (and not the selected one). Any help? Thanks Anand -- 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.
Never mind - I found it - I needed to add :method => :get to the form_tag and it worked. On Dec 22, 11:47 am, Anand Ramanathan <rcan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rails 3: I have a view books/:id/show.html.erb - in the view, I have a form > with a select tag to pick a template, that on dropdown should submit the > form which rerenders the page based on the selection: > > <%= form_tag book_path(@book) do %> > > > <%= select_tag "template[]", > >> options_for_select([["Template1","template1"], ["Template2", "template2"]]), > >> :value => (@template || ''template1''), :onchange => ''this.form.submit();'' %> > > > <%end%> > > In my controller, I have > > > @template = params[:template] || ''post'' > > In my routes, I have > > resources :books, :only => [:show] > > and rake routes indeed shows > > book GET /books/:id(.:format) > > > {:controller=>"books", :action=>"show"} > > When I first navigate to this view, it all works fine and the view renders > as expected. If I select a different template from the dropdown, I get the > error: > > No route matches ''books/1'' > > The funny thing is that the current page is exactly that route. > > If I refresh the page, it renders with the default template (and not the > selected one). > > Any help? > > Thanks > Anand-- 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.
Apparently Analagous Threads
- how to combine unequal rows and columns in R
- Question about templates from variables
- [PATCH nbdkit] server: Allow file descriptors to be passed to nbdkit_read_password.
- Questions on writing plugin for merb
- Postgres, testing and maybe spurious database DROPpings?