I have a main model called ‘Notes’ which has the following:
attr_accessible :name, :label_tokens
has_many :labelships
has_many :labels, :through => :labelships
attr_reader :label_tokens
So basically the Note_id & Label_id are kept in the Labelships table.
What i would like to do is create a list of distinct Labels and create a link on each value to the respective Note.
Example: Note ‘mynote’ has a label of ‘git’ associated through the labelship table, i would like Git to appear on a list of other labels, and then when i click on git, i get a list of Notes that have the label ‘git’ on them.
Assuming you have the following models:
Now given a label, you can get its notes as follows:
To exclude the note in hand: