How to set up my belongs_to and has_many reference

Posted by dagda1 on Stack Overflow See other posts from Stack Overflow or by dagda1
Published on 2010-03-22T23:42:28Z Indexed on 2010/03/22 23:51 UTC
Read the original article Hit count: 342

Filed under:
|

Hi,

I have an ExpenseType object that I have created with the following migration:

class CreateExpenseTypes < ActiveRecord::Migration
  def self.up
    create_table :expense_types do |t|
      t.column :name, :string, :null => false
      t.timestamps
    end
  end

I can see the table name is the pluralised expense_types. My question is, how do I reference this type in a belongs_to relationship?

Is it:

belongs_to :expensetype

or is it

   belongs_to :expense_type

I do not seem able to set it up correctly.

Cheers

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about ruby