I am currently attempting to build a model using Ruby on Rails. As of now, I am trying to separate posts based upon their ‘tags’ (which is a column in my posts model) – I want all ‘sports’ articles, for example, to pop up on a separate page. Tags are assigned to a post via text-field. However, I can’t seem to come to a conclusion as to how I’d be able to complete this task.
Here is some code I’ve tried out within my posts model:
def self.getTag
find(:all, :include => params[:tags], :order => 'created_at DESC')
end
However, it seems as if params[:tags] is an invalid argument.
paramsis not available (and should not be used) in the model. Just pass a parameter to the model method: