In a rails project, I use inherited_resources 1.5.0 gem
. I have below model:
forums_controller.rb
:
class ForumsController < InheritedResources::Base
respond_to :json
skip_before_filter :verify_authenticity_token
def permitted_params
params.permit(vocabulary: [:name])
end
end
forum.rb
:
class Forum < ActiveRecord::Base
attr_accessible :name
end
Now when I want create new forum, I post params to rails project, In this state, I have a problem:
when I use attr_accessible :name
in my forum model(forum.rb
), I get below error in server log and forum don't save to database:
Started GET "/forums" for 127.0.0.1 at 2014-08-09 11:51:42 +0430
ActionController::RoutingError (undefined method 'attr_accessible' for #<Class:0x000000064c0468>):
app/models/forum.rb:2:in '<class:Forum>'
app/models/forum.rb:1:in '<top (required)>'
app/controllers/forums_controller.rb:3:in '<top (required)>'
and when I remove attr_accessible :name
in my forum model, new forum save to database with empty name
. How can I fix this problem?