Completing the Sponsor model and views

Maybe I am missing something, but why would I need a has_many in my lookup tables?

What I need: in my sponsors table, I need to have the corresponding sponsor_type_id. I have a belongs_to :sponsor_type in my sponsor model and it is doing exactly what I need. It works correctly throughout the app and I even looked at the records in the db and they contain what I was expecting. Is this the right way to do it?

Is there a preference to use has_many in the lookup table model instead of belongs_to in the main entity model? Does it make a difference performance wise or does it affect some of the auto generated methods which makes it easier for object retrieval in some cases?

On August 6, 2014 at 2:56:30 PM, Nikita Avvakumov (notifications@github.com) wrote:

In app/models/sponsor_type.rb:

> @@ -0,0 +1,6 @@
> +class SponsorType < ActiveRecord::Base
> +
> +  validates :name, presence: true, uniqueness: true
> +  validates :code, presence: true, uniqueness: true
> +   
has_many :sponsors?

—
Reply to this email directly or view it on GitHub.