Ruby on rails Rails-UsersController#create中的ArgumentError-参数太少

Ruby on rails Rails-UsersController#create中的ArgumentError-参数太少,ruby-on-rails,authentication,devise,arguments,Ruby On Rails,Authentication,Devise,Arguments,这可能是非常基本的,但我似乎无法理解 基本上,当我尝试使用表单创建新用户时,用户详细信息已经存在且不唯一,我收到以下错误: ArgumentError in UsersController#create too few arguments Application Trace | Framework Trace | Full Trace app/controllers/users_controller.rb:61:in `format' app/controllers/users_contro

这可能是非常基本的,但我似乎无法理解

基本上,当我尝试使用表单创建新用户时,用户详细信息已经存在且不唯一,我收到以下错误:

ArgumentError in UsersController#create

too few arguments

Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:61:in `format'
app/controllers/users_controller.rb:61:in `create'
这是我在我的
user\u controller.rb中的
创建
操作:

  # POST /users
  # POST /users.xml
  def create
      @user = User.new(params[:user])

        if @user.save
          flash[:notice] = 'User successfully created' and redirect_to :action=>"index"
        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
        end
      end
    end
这是我的
user.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :username, :password, :password_confirmation, :remember_me

  validates :email, :username, :presence => true, :uniqueness => true
end
class用户true、:university=>true
结束
这是我的表格:

<%= simple_form_for(@user) do |f| %>
  <div class="field">
    <%= f.input :username %>
  </div>
  <div class="field">
    <%= f.input :email %>
  </div>
    <div class="field">
      <%= f.input :password %>
    </div>
    <div class="field">
      <%= f.input :password_confirmation %>
    </div>
  <div class="actions">
    <%= f.button :submit %>
  </div>
<% end %>

在这种情况下,
格式是什么


没有
响应
块,请将其放回!您正在引用一些其他的
格式

通过不同的rails版本,代码的确切布局发生了一些变化(请发布您使用的版本-检查文件)

此示例适用于rails 3+(它是使用3.2.5生成的,但应适用于所有3+或至少3.1+版本)


p、 很好的选择与简单的形式,它使生活更容易

是的,这就是我所说的对
块的
响应。“精确的布局”并不重要,但是——没有理由不使用OP已有的内容。谢谢!:我知道这是一件简单的事情哈哈顺便说一句,我使用的是Rails 3.2
def create
  @user = User.new(params[:user])

  respond_to do |format|
    if @user.save
      format.html { redirect_to @user, notice: 'Blob was successfully created.' }
      format.json { render json: @user, status: :created, location: @user}
    else
      format.html { render action: "new" }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end