I hit my head against a wall trying to figure out how to get Devise to work with client registration ....
So, on my landing page, I want to show the registration form, so I added this to my opinion:
<%= render 'devise/registrations/new' %>
In this partial, I mean a form tag, for example:
<%= form_for(user_registration_path, :url => user_registration_path) do |f| %>
.
.
In my application layout I have:
<% flash.each do |key, value| %>
<div class="flash <%= key %>"><%= value %></div>
<% end %>
The problem I am facing is when I submit a new registration form with invalid parameters, I don’t see an error message?
But if I submit valid information, the form says that it worked, and that I need to check my email address to confirm that it’s good.
Can you help me figure out how to get this working 2-end so that I can display errors:
Here is my full controller:
def new
respond_to do |format|
format.json { render :json => @user }
format.xml { render :xml => @user }
format.html
end
end
def edit
respond_to do |format|
format.json { render :json => @user }
format.xml { render :xml => @user }
format.html
end
rescue ActiveRecord::RecordNotFound
respond_to_not_found(:json, :xml, :html)
end
def create
@user = User.new(params[:user])
if @user.save
respond_to do |format|
format.json { render :json => @user.to_json, :status => 200 }
format.xml { head :ok }
format.html { redirect_to :action => :index }
end
else
respond_to do |format|
format.json { render :text => "Could not create user", :status => :unprocessable_entity }
format.xml { head :ok }
format.html { render :action => :new, :status => :unprocessable_entity }
end
end
end
Model:
validates :fname, :presence => true, :length => { :minimum => 2 }
validates :lname, :presence => true, :length => { :minimum => 2 }
validates :password, :presence => true, :length => { :minimum => 6 }
validates :email, :presence => true, :length => { :minimum => 6 }