RailsCasts Pro episodes are now free!

Learn more or hide this

Djongo's Profile

GitHub User: djongo

Comments by Djongo


And in anyone else has a similar issue, the solution was simple. I had tried already but not for all my hmts at the same time, so didn't get the right outcome. All you have to do is make an alias like this:

has_many: reader_persons, :through => :persons, :source => :person

def reader_tokens=(tokens)
self.reader_person_ids = Person.ids_from_tokens(tokens)

and similar for writer_persons


I have an issue with several has many throughs connecting the same models. As an example Book and Person connected through Reader and Writer. How does my equivalent of "author_tokens" setter method distinguish which one to save?
I have made reader_tokens and writer_tokens methods, but when they do
self.person_ids = Person.ids_from_token(tokens) I can't name the relationship (reader or writer). Should I move my method to the relationship models, or how can I modify them, so they work?