I'm new to rails!
Ok, I am trying to set up a user signup form.
It is mapped as a singular resource in the routes
map.resource :user
And trying to create the user through the console works fine.
the controller code for user's signup is as follows:
def signup
@user = User.new#(params[:user])
end
def create
@user = User.new(params[:user])
#debugger
if request.post?
if @user.save
session[:user] = User.authenticate(@user.login, @user.password)
flash[:message] = "Signup successful"
redirect_to registries_path
else
flash[:warning] = "Signup unsuccessful"
#redirect_to 'user/signup'
end
end
end
The signup view is as follows (and this is where i think something is going wrong)
<% form_tag user_path do %>
<p>User creation.</p>
<p><%= error_messages_for 'user' %></p>
<p>
<label>Username:</label>
<%= text_field_tag 'login', nil, :size => 20, :maxlength => 20 %>
</p>
<p>
<label>Password:</label>
<%= password_field_tag 'password', nil, :size => 20, :maxlength => 20 %>
</p>
<p>
<label>Password confirmation:</label>
<%= password_field_tag 'password_confirmation', nil, :size => 20, :maxlength => 20 %>
</p>
<p>
<label>Email:</label>
<%= text_field_tag 'email' %>
</p>
<p><%= submit_tag 'Signup' %></p>
<% end %>
Now, that page renders just fine. I've called the form on the "user_path" which is singular (i think?). But when I hit the submit button, it gives me an error saying that
uninitialized constant UsersController
the occurence of the error makes sense, since User is meant to be singular, so if it is trying to call the Users controller, it should be chucking an error.
When I checked the server log, it shows this message:
Processing ApplicationController#create (for 127.0.0.1 at 2010-05-08 16:26:14) [POST]
Parameters: {"commit"=>"Signup", "password_confirmation"=>"[FILTERED]", "action"=>"create", "authenticity_token"=>"yOcHY+rMjaqmu9HS8EwnDqJKbc0Zxictc0y4dtD26ac=", "controller"=>"users", "login"=>"
bob", "password"=>"[FILTERED]", "email"=>"
[email protected]"}
NameError (uninitialized constant UsersController):
In the params, I can see that it is calling the "users" controller. But I'm not sure how to fix that, or what is causing it to call the "users" controller as opposed to the "user" controller.
Any ideas?
Thanks in advance!