[Rails] Re: Modelling Foreign Keys
Arch Stanton
d6veteran at gmail.com
Sat Apr 1 01:25:08 GMT 2006
Steve Koppelman wrote:
> In this case, why won't it?
>
> In your user model, you'd say
>
> has_many :posts
>
> and in the post model you'd say
>
> belongs_to :user
>
> and that's all you need for what you describe. What's not working?
>
Well in the view I get no visibility to the foreign keys. Just now I
found this example:
class Student < ActiveRecord::Base
set_table_name "students"
set_primary_key "id"
belongs_to :advisor, :class_name=>"Advisor", :foreign_key =>
"advisor_id"
belongs_to :second_advisor, :class_name=>"Advisor", :foreign_key =>
"sub_advisor"
has_and_belongs_to_many :courses, :class_name=>"Course"
end
I want my posts/edit to allow me to select a user.
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list