I’m trying to access the company_name from Cdetail that is associated
with the company_id in Position (which is actually the user id in the
User model.
Maybe my naming conventions are wrong ? I’m not sure how to get it to
work.
Any ideas ?
Well, I’m not exactly sure what you are trying to do, but it seems
that Position is a “Has And Belongs To Many” relationship, so maybe
use has_many :through? I’m sure this doesn’t really answer your
question, but I don’t really get the question.
Well, I’m not exactly sure what you are trying to do, but it seems
that Position is a “Has And Belongs To Many” relationship, so maybe
use has_many :through? I’m sure this doesn’t really answer your
question, but I don’t really get the question.
-carl
I’ll hold off on rephrasing the question but I have been thinking of
HABTM
positions can have many users and cdetails
users and cdetails can have many positions
I think Well I’ll own up to it since it’s my schema.
Essentially though the company_name is in the cdetails table and is
associated with the user id in the users table. positions column
company_id is the same as the user id. If that complicates it …i
mean makes it any clearer.
Decide to re-phrase my question - though I’m reading through the model
relationship material again.
Again here are my three models / methods
Position - company_id
User- id
Cdetail - user_id , company_name
So the column company_id is the same as the id (in the User model).
When a user creates a Position their user id goes into the company_id
column.
In the Cdetail model, the user_id relates to the User model id column.
In addition though it has a column for the user to enter their
company name (company_name).
If this is any clearer, I’m trying to figure out the best way when
searchign through the Positon model , to take that company_id and spit
out the company_name.
Stuart
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.