Ruby ActiveModel::MassAssignmentSecurity::ApiUsersController#create中出错
我无法创建新的api_用户。每次我尝试创建它时,我都会Ruby ActiveModel::MassAssignmentSecurity::ApiUsersController#create中出错,ruby,ruby-on-rails-3,Ruby,Ruby On Rails 3,我无法创建新的api_用户。每次我尝试创建它时,我都会 Can't mass-assign protected attributes: utf8, authenticity_token, api_user, commit, action, controller 这是我的模型api\u user.rb class ApiUser < ActiveRecord::Base attr_accessible :api_key, :count, :email, :name, :organizat
Can't mass-assign protected attributes: utf8, authenticity_token, api_user, commit, action, controller
这是我的模型api\u user.rb
class ApiUser < ActiveRecord::Base
attr_accessible :api_key, :count, :email, :name, :organization
end
class ApiUsersController < ApplicationController
#skip_before_filter :verify_authenticity_token
def new
@api_user = ApiUser.new
end
def create
@api_user=ApiUser.create(params)
render :text=>"#{@api_user.id}"
end
def destroy
@api_user=ApiUser.find(params[:id])
@api_user.destroy
render :text=>"Deleted successfully"
end
end
我使用的是Ruby 1.9.2和Rails 3.2.3为了创建ApiUser,您应该只使用正确的参数:
@api_user=ApiUser.create(params[:api_user])
并非所有的params
hash