I’ve got the an has_one association:
has_one association user -> customer models
will the user have the customer_id or customer will have the user_id attribute?
other question: into my _form i’d like to have a select/option with all the users that hasn’t associated with a customer which is the best way to do that?
thanks a lot.
The _id field is always in the model with the belongs_to, and refers to the other table name.
In this case, the customers table will have a user_id field.
For the second question, missing values are found in SQL using outer joins.
The SQL you want would be
In ActiveRecord, add a scope to your User class.
In Rails 3.x:
In Rails 2.3.x: