Apparently, I am using params[:category] (from routing...) to categorize some articles within same table, and I just want to set the category column of an article to be params[:category]. I tried just saying
class Article < ActiveRecord::Base
has_many :comments
belongs_to :article_category # this is the model that has info about categories
category = params[:category]
end
but above validation throws out
undefined local variable or method `params' for #<Class:0x3c4ad30>
error.
How can I use params[:category]??
Also, how can I be assure that params[:category] will be one of categories listed in article_categories database table? I don't want user to mannually type in the address for random category and insert it in the table.