A
Allen Walker
I have a drop down list in my view. In my model I have the following:
ARTICLE_CATEGORIES = [
["News", 1], ["Article", 2], ["Review", 3]
]
validates_inclusion_of :category, :in => ARTICLE_CATEGORIES.map { |disp,
value| value }
I want to extract out all "Article" types in my controller.
So in my controller: (I have a 'category' field in my 'articles' table)
@news = Article.find_by_category(ARTICLE::ARTICLE_CATEGORIES.find...??)
Not sure how to do this. I want to get the ID (in this case 2) from the
ARTICLES_CATEGORIES array but I want to extract it out of this array
using the key "Article".
Thanks
ARTICLE_CATEGORIES = [
["News", 1], ["Article", 2], ["Review", 3]
]
validates_inclusion_of :category, :in => ARTICLE_CATEGORIES.map { |disp,
value| value }
I want to extract out all "Article" types in my controller.
So in my controller: (I have a 'category' field in my 'articles' table)
@news = Article.find_by_category(ARTICLE::ARTICLE_CATEGORIES.find...??)
Not sure how to do this. I want to get the ID (in this case 2) from the
ARTICLES_CATEGORIES array but I want to extract it out of this array
using the key "Article".
Thanks