Active Record Associations

Hi,

I think the problem you're having here is that you're calling 'qty' when your table column is 'Qty'.

There are also a number of things that are not set up in a way that will give you the benefit from Rails:

It's generally standard to keep all of your column names lowercase. If you can, it's also best to be as descriptive as possible. For example, 'description' is better than 'Desc'.

Your Post_Type class would be better named without the underscore: PostType. If you do this, you shouldn't need to specify the foriegn key as you have in your relationship declarations.

For readability, I would also be more descriptive in your controllers and views:

def index   @post_types = PostType.find(:all) end

<% @post_types.each do |post_type| %>

In terms of your models, I don't know exactly what you application is but I would say your method would work. However, I would suggest looking at 'tagging' and 'polymorphic' relationships in Rails as you may be able to achieve a neater, more managable solution.

Steve

Also consider what Jeff has said :0)

(didn't spot that during my waffling!)

Steve

Your namings completely messed up. Conventions is really important in Rails, it's just not supposed to work that way. Table names should be in lower case separated by dash, while model name is camel case. like post_types/PostTypes, text_books/TextBooks etc. Just learn more about Rails.

what is the difference between supplies, textbooks and miscs? seems like you have to rework domain model design as well...

What you need are two separate tables, items and item_types (supplies, textbooks, misc are item_types in fact) Item belongs_to :item type, ItemType has_many :items. Then all your items, despite of its item type will go to items table. Department looks like separate entity too. Foreign keys should be integers, not strings. Allow null, where it will not break things apart. I bet there are lots of things to alter, you'd better to learn more on the topic, at least on domain model design and rails basics.