我正在制作一个Rails 3.1应用程序,有一个注册表单曾经正常工作,但我似乎改变了一些东西以破坏它...我正在使用Twitter bootstrap和twitter_bootstrap_form_for gem。我进行了一些更改,搞乱了表单字段的格式,更重要的是,当我提交注册表单以创建新用户时,信息显示在URL中,看起来像这样:
这让我遇到了与上述相同的问题。
添加routes.rb文件:
编辑:这在最新版本的Chrome和Firefox中发生
这是表单的代码:
<div class="span7">
<h3 class="center" id="more">Sign Up Now!</h3>
<%= twitter_bootstrap_form_for @user do |user| %>
<%= user.email_field :email, :placeholder => 'me@example.com' %>
<%= user.password_field :password %>
<%= user.password_field :password_confirmation, 'Confirm Password' %>
<%= user.actions do %>
<%= user.submit 'Sign Up' %>
<% end %>
<% end %>
</div>
这里是UsersController的代码:
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to about_path, :notice => "Signed up!"
else
render 'new'
end
end
end
我不确定你是否需要更多内容,如果有,请告诉我!谢谢!
编辑:为了调试,我尝试指定:post并使用普通的form_for。
<%= form_for(@user, :method => :post) do |f| %>
<div class="field">
<%= f.label :email %>
<%= f.email_field :email %>
</div>
<div class="field">
<%= f.label :password %>
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
</div>
<div class="actions"><%= f.submit "Sign Up" %></div>
<% end %>
这让我遇到了与上述相同的问题。
添加routes.rb文件:
Auth31::Application.routes.draw do
get "home" => "pages#home"
get "about" => "pages#about"
get "contact" => "pages#contact"
get "help" => "pages#help"
get "login" => "sessions#new", :as => "login"
get "logout" => "sessions#destroy", :as => "logout"
get "signup" => "users#new", :as => "signup"
root :to => "pages#home"
resources :pages
resources :users
resources :sessions
resources :password_resets
end