我正在使用设计,如果您尝试使用现有电子邮件注册,则会遇到问题。
当您注册时,您可以从此网址中执行此操作:
http://localhost:3000/accounts/new
所以我有一个帐户,我添加了一个用户(设计)。如果我尝试注册为已存在的用户,我会收到正确的错误:
“用户已收到电子邮件”
但它会重定向到http://localhost:3000/accounts
控制器看起来有点像这样:
def create
name = account_params[:name]
first_name = Modules::NameHelpers.get_first_name(name)
last_name = Modules::NameHelpers.get_last_name(name)
@account = Account.new(account_params_wo_user_name)
@account.users.first.first_name = first_name
@account.users.first.last_name = last_name
respond_to do |format|
if @account.save
sign_in @account.users.first
format.html { redirect_to root_path, notice: "Thanks for signing up." }
format.json { render action: 'show', status: :created, location: @account }
else
format.html { render action: 'new' }
format.json { render json: @account.errors, status: :unprocessable_entity }
end
end
end
我似乎无法找到重定向到索引页的内容。
更新: 这是表格:
<%= form_for(@account) do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<div>
<%= f.label :name, 'Account Name' %> <br />
<%= f.text_field :name, :required => true, :placeholder => 'Your account name' %>
</div>
<%= f.fields_for :users do |user_form| %>
<div><%= user_form.label :name %><br />
<%= user_form.text_field :name, :autofocus => true, :required => true, :placeholder => 'Your name' %></div>
<div><%= user_form.label :email %><br />
<%= user_form.email_field :email, :required => true, :placeholder => 'Your email' %></div>
<div><%= user_form.label :password, :required => true %><br />
<%= user_form.password_field :password, :required => true, :placeholder => 'Enter a 8 character password'%></div>
<div><%= user_form.label :password_confirmation, :required => true %><br />
<%= user_form.password_field :password_confirmation, :required => true, :placeholder => 'Confirm password' %></div>
<% end %>
<div><%= f.submit "Sign up" %></div>
<% end %>