0

I have been using the ruby gem 'acts_as_votable' (https://github.com/ryanto/acts_as_votable) and have been pleased with its ease of use.

My problem arises from the gem's lack of explicit controller creation. Without the controller (and model, so no fallback to attr_accessible) I am unable to edit the strong parameter whitelist. I therefore can't pass a value to a new column I have added to the votes db.

I've tried creating my own Votes controller, pasting in the 'voter_params' (with my additional param) from the gem's lib/extenders/controller.rb resulting in no success.

If anybody knows how I could add to this parameter whitelist it would be much appreciated.

Thanks!

1 Answers1

0

Add the following into your Config > initializers > acts_as_votable.rb

module ActsAsVotable
  ActsAsVotable::Vote.class_eval do
      attr_accessible :votable, :voter, :vote_scope
  end
end
Learner
  • 4,596
  • 1
  • 20
  • 23
  • This doesn't work unfortunately. It also requires the 'protected_attributes' gem which I was trying to avoid. My attempt at a rails 4 strong params version (which also failed) was as follows: `ActsAsVotable::Vote.class_eval do def votable_params(params_object = params[:vote]) params_object.permit(:vote_registered) end def voter_params(params_object = params[:vote]) params_object.permit(:votable_id, :votable_type, :voter_id, :voter_type, :votable, :voter, :vote_flag, :vote_scope, :vote_time) end end` – user3811886 Feb 16 '15 at 07:13