so to use your statement, I should put the following in my Associate
model?

belongs_to :watching_channel, :class_name => "Channel", :foreign_key
=>
"watching_channel_id"

-Janna B

On Jul 17, 1:09 am, Rodrigo Dominguez <rails-mailing-l...@andreas-
s.net> wrote:
> Janna Brossard wrote:
> > yes, current_associate.watching_channel_id IS a foreign key to
> > channel.id. But I have not specified it as such in the associate model
> > or the channel model (not sure how -- or if I even need to!) -Janna
>
> if the class name is WatchingChannel, the it will work
>
> belongs_to :watching_channel
>
> if the class name of the watching channel is something else, like
> Channel, then it will work
>
> belongs_to :watching_channel, :class_name => "Channel", :foreign_key =>
> "watching_channel_id"
>
> it's always false because either @channel is not null, the foreign key
> is not null or the foreign key is zero.
>
> Note that you should never have a foreign key with a zero value
>
> If you make the modification in your model, you can easily do
>
> if �...@channel.nil? and current_associate.watching_channel
>
> and finally
>
> @channel.nil? and @channel == nil is almost the same thing,
> @channel.nil? is easier to read, dough
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to