Skip to content

acts_as_votable_options somehow became nil #193

@Decoydoll

Description

@Decoydoll

Here is my web app environment:

Rails           : 5.2.2
acts_as_votable : 0.12.0

Here is the stack trace that i got:

…cts_as_votable-0.12.0/lib/acts_as_votable/cacheable.rb: 107:in `update_cached_votes'
…/acts_as_votable-0.12.0/lib/acts_as_votable/votable.rb: 101:in `block in vote_by'
…rd/connection_adapters/abstract/database_statements.rb: 259:in `block in transaction'
…ive_record/connection_adapters/abstract/transaction.rb: 239:in `block in within_new_transaction'
       /opt/rubies/ruby-2.4.1/lib/ruby/2.4.0/monitor.rb: 214:in `mon_synchronize'
…ive_record/connection_adapters/abstract/transaction.rb: 236:in `within_new_transaction'
…rd/connection_adapters/abstract/database_statements.rb: 259:in `transaction'
…s/activerecord-5.2.2/lib/active_record/transactions.rb: 212:in `transaction'
…/acts_as_votable-0.12.0/lib/acts_as_votable/votable.rb:  96:in `vote_by'
…...............app/controllers/api/votes_controller.rb:  24:in `create'

Here is the error message:

NoMethodError: undefined method `[]' for nil:NilClass

After lookin for the code, here is the part of code that throw that error

self.send(acts_as_votable_options[:cacheable_strategy], updates) if updates.size > 0

which call acts_as_votable_options that is assigned in https://github.com/ryanto/acts_as_votable/blob/599995f7ec5aa0f8a04312768fc956e9003d32d4/lib/acts_as_votable/extenders/votable.rb#L24-#L31
which, per my understanding will never be nil except there is another assignment.

My model only calls acts_as_votable without any args so i assume it will use the default options.

Anyone can explain why this could happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions