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