wow!  i was pretty far off :)  thanks for the tips!  i would like to
know more about when/where and what the implications are for using the
has_one, belongs_to, etc. keywords.  any links that would help me
better understand what the hell i'm doing ? :)


btw... i DO get what you are saying...  after changing the belongs_to
and has_one...  i can just do this in my view:

<p>
  <b>Gi or No-Gi:</b>
  <%=h @division.gi_map.name %>
</p>


thanks again!

On Sep 6, 12:53 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Sep 6, 5:36 pm, Ron DeMeritt <[EMAIL PROTECTED]> wrote:> this is my first 
> application in RoR and am kind of stuck.  part of my
> > confusion is where/when to use the model, controller or view.
>
>  class Division < ActiveRecord::Base
>
>
>
> >   belongs_to :match
>
> >   def self.gi_map_name
> >     GiMap.first(:conditions => ["id = ?", self.id]).name
> >   end
> > end
>
> You've created a class method (that's what def self. does) whereas
> this should really be an instance method.
> Usually you'd handle this via some associations. GiMap should have
> has_one :division (and not belongs_to :division - that would indicate
> that the gi_maps table has a division_id column) and division should
> belongs_to :gi_map (and it does as required have a gi_map_id column).
>
> Then you'd just write (I suspect that personally I wouldn't bother)
>
> def gi_map_name
>   gi_map.name
> end
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to