newbie: has_many/belongs_to trouble in my view

i'm trying to learn some rails and have been doing great up to now.
i have a has_many/belongs_to relationship. i got the new/edit forms
working with a select box and i confirmed the urischeme_id shows up in
the websites table properly.

the problem is when i try to show the urischeme.scheme in my view. i
keep getting errors. i tried pluralizing, caps, and everything i can
think of!!! what am i doing wrong? i have been struggling with this
for hours.


// relevant models
class Website < ActiveRecord::Base
  belongs_to :clubs
  belongs_to :urischemes
  validates_presence_of :name, :address, :urischeme_id

class Urischeme < ActiveRecord::Base
  has_many :websites
  validates_presence_of :scheme

// controller
def show
    @club = Club.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml { render :xml => @club }

// my view code with comments added for this email
<% unless @club.websites.nil? %>
   <% @club.websites.each do |website| %>
        <%=h website.address -%> // works fine
        <%= debug(website) -%> // no error, shows a proper
        <%= debug(website.urischeme) -%> // undefined method
`urischeme' for #<Website:0x477cd5c>
        <%= debug(website.urischeme.scheme) -%> // undefined method
`urischeme' for #<Website:0x4743d90>
    <% end %>
<% end %>

You haven't defined an association for urischeme.scheme (the validation
doesn't count as an association and may be wrong as well).

scheme is a column in my urischeme table (see my migration below), why
would I have to define a seperate association? the tables should be
associated by
Website = belongs_to :urischemes
Urischeme = has_many :websites

as for the validations, I was just playing with them to learn how they
work. they actually seem to work, plus if i delete them, i still get
the same errors as above. so I don't think they are causing my

// the migration i used for creating the urischeme table
class CreateUrischemes < ActiveRecord::Migration
  def self.up
    create_table :urischemes do |t|
      t.string :scheme


  def self.down
    drop_table :urischemes

Your association is belongs_to :urischemes, so it will create a website.urischemes method, but you're calling website.urischeme

Your association should be belongs_to :urischeme (a belongs_to is always singular)


I knew it would be a simple fix.