Rails: Where should I put this method? -
i have multiple models in application different types of content, , need whichever 1 published. @ moment, i'm using helper_method :latest_content
in application controller.
is best place put method? if so, how should write rspec tests it?
sounds have common functionality across multiple models. rails has concerns
allow that.
# app/models/concerns/searchable.rb module searchable extend activesupport::concern module classmethods def last_content # ... here whatever content of :last_content end end end # app/models/model_x.rb class modelx < activerecord::base include searchable ... end # app/models/model_y.rb class modely < activerecord::base include searchable ... end
Comments
Post a Comment