##controllers 文件
def new @user = Users.new end
def create @user = Users.new(params[:user]) if @user.save redirect_to :action => :index flash[:notice] = "event was successfully created" else render :action => :register end end
<%= form_for @user, :url => { :controller => 'users', :action => 'create'} do |f| %>
<%= f.text_field :name,:class => "txt-ctrl"%>
<% if @user.errors.any? %>
<%= f.submit "注册" > <% end %>
在 create 函数里面,@user出来的都是空值。。