def new
@title = "Create a user"
@user = User.new
end
<%= form_for(@user) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email%>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirmation" %><br />
<%= f.password_field :password_confirmation %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
when i try submit my form to create a new user, i get a message “You are already signed in.” and the user does not get created what could be the problem?
As mentioned in my comment you have to tell Devise you want to use a custom controller for registrations, so it knows not to use it’s default behaviour.
Since you want to restrict users from registering publicly, I think (I didn’t test this) you have to create your own custom registrations controller, which does the same thing as devise defaults one, except only if a user is already logged in… I’m not sure though what exactly happens after the (not public) registration is finished. Cause Devise tries to log you in automatically – depending if you’re using confirmable or not… But my guess would be that you get logged out as the old user and logged in as the new one…
So to give you directions you should read the README section concerning Configuring Controllers.
And then you could try simply to add a the before_filter to authenticate a user in your custom registrations controller (assuming your user model is called
User):But again. I didn’t test this… so maybe it’s not the way to do it, but it’s worth a try 🙂