migrating a Rails 3.2 app to strong parameters and getting this error -


i have rails 3.2. app , getting error on following scope:

class location < activerecord::base   include activemodel::forbiddenattributesprotection    scope :active, -> { where(is_deleted: false) } 

with view fragment:

<% @location.order('updated_at desc').active.where('menu_event_category_id ?',nil).each_with_index |x, idx| %> 

the error is:

actionview::template::error (undefined method `active' #<class:0x0000011da42c20>): 

why getting error , how fix it?.

this has nothing strong_parameters. need use scope:

<% location.active.order('updated_at desc').where('menu_event_category_id ?',nil).each_with_index |x, idx| %> 

or..

<% @location.active.order('updated_at desc').where('menu_event_category_id ?',nil).each_with_index |x, idx| %> 

further, should set @locations in controller:

@location = location.active.where('menu_event_category_id ?',nil) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -