views:

675

answers:

2

Hi, this question is related to routing-filter.

I have this in my view:

<% form_for :post, :url => {:action => "show"} do |f| %>

which translates in the browser to this:

<form action="/en/posts/show" method="post">

after changing the I18n.locale e.g.

I18n.locale = :en

the html becomes:

<form action="/en/posts/72" method="post">

and the action is not working and I get this error:

Unknown action

No action responded to 72.

Sure, there is no action like 72. This number is the show action's input of course. And it is correct post number. So if I put this address localhost:3000/en/posts/72 to the browser, then it gives me the page without a problem.

So why it doesn't work in the form then?

Thanks.

A: 

I just found that is not related to the routing filter. But Rails generates different html form tags depending on what's in the url. Which is still strange to me. Anyone?

valk
+1  A: 

Specify a method like that:

<% form_for :goal, :url => { :action => 'show' }, :html => {:method => :put} do |f| %>

It worked for me.

Alex