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

Reply via email to