Hi all,
I made a resource controller for my User model like this:
merb-gen resource_controller users
After that I decided to make the view for the 'new' action first, so I
write this into new.html.erb:
<%= form_for @user do %>
<div><%= text_field :login, :label => 'Login' %></div>
<div><%= password_field :password, :label => 'Password' %></div>
<div><%= password_field :password_confirmation, :label => 'Password
again' %></div>
<%= submit "submit" %>
<% end =%>
... just as the merb documentation has it. However, that produces the
following html:
<form method="post" action="/user">
...
</form>
So when the form is submitted, I receive an error:
Controller 'User' not found. If Merb tries to find a controller for
static files....
Since the controller's class name is Users, I amended the form_for
line likewise:
<%= form_for @user, :action => "/users/create" do %>
and all worked like a charm.
However, I am not fully content with this. For one, the documention
says that 'Generates a resource specific form tag which accepts a
block, this also provides automatic resource routing.', so I gather
that form_for should work out-of-the-box, without specifying
the :action parameter. Also, it would be tedious to tweak all the form
actions in the manner presented above. Also, the route definitions did
not seem to miss anything:
Merb::Router.prepare do
resources :users
resources :user
...
Am I missing something that makes this right? (possible) If not, what
is the nicest solution? Modifying action urls, setting up routes or
something else?
Thank you in advance,
Balint
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" 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/merb?hl=en
-~----------~----~----~----~------~----~------~--~---