In my Rails 3.2 app I have a has_and_belongs_to_many :notes
association on Profile
. Note
has a type on it - "urgent" or "standard". (Note
has_and_belongs_to_many :profiles
.)
I'd like to be able to do something like profile.urgent_notes
without building it in a method like:
def urgent_notes
urgent_notes = Array.new
goals.each do |g|
if g.type == "urgent"
urgent_notes << g
end
end
urgent_notes
end
So is there a clean way to do this by adding another association? Or would something like a scope be best?