我无法创建新的 api_user。每次我尝试创建它时,我都会得到
Can't mass-assign protected attributes: utf8, authenticity_token, api_user, commit, action, controller
这是我的模型api_user.rb
class ApiUser < ActiveRecord::Base
attr_accessible :api_key, :count, :email, :name, :organization
end
控制器api_users_controller.rb
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