Hi,

I'm a Java and ColdFusion developer trying to find my feet with JRuby
and Rails.

I've created a very simple "Auction" app, with a database schema like
this:

  create_table "auction_items", :force => true do |t|
    t.string   "description"
    t.string   "title"
    t.datetime "start_date"
    t.datetime "end_date"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "bids", :force => true do |t|
    t.integer  "auction_item_id"
    t.decimal  "amount",          :precision => 15, :scale => 2
    t.datetime "bid_time"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

There are two classes in my model:

auction_item.rb:

class AuctionItem < ActiveRecord::Base
  has_many :bids
end

bid.rb:

class Bid < ActiveRecord::Base
  belongs_to :auction_item
end

Initially, I had bid.rb like this:

class Bid < ActiveRecord::Base
  belongs_to :AuctionItem
end

(ie. using the camel-cased class name, as per the definintion in the
class  rather than the underscored one), but it didn't work until I
changed it to use the undscored one.

What is the rule here?  Does the name in the "belongs_to" refer to the
table name or something?

Similarly, I'm a bit confused why I have to go to

http://localhost:8080/auction_items (not
http://localhost:8080/AuctionItems).

Can anyone explain the general rules to me, or point me to somewhere
that does please?

Many thanks,
Andrew.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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