Posts [ 4 ]

Topic: Optimizing Code for Bookselling Site

Hi there

I'm a little new to RoR. I'm building a book selling site for 10 different cities. I have a working codebase that works for one city. I have an Item model that maps to an Items table. I want to expand to incorporate the other cities, but I'm not sure if I should have different Item table for each city. If I wanted a different table for each city, would I need a separate model and controller and view?

Re: Optimizing Code for Bookselling Site

It would be better to have 1 cities table, and 1 items table.. You simply have a column in your items table called 'city_id' that refers to the id of one of the cities in your City table.Then you can use active record associations (has_many :ites, and belongs_to :city) to utilize that relationship in your code.