Finding a Guide to Structuring Ecommerce Applications

I am looking for a guide for a personal mine project at RoR. I learned RoR using Michael Hartl's online book, and now I'm building another app for my own edification.

My web app will be like an e-commerce website, except for selling products, I will be selling menu items from a restaurant. I've already implemented a users resource that stores basic information (name, email, etc.), but I'm looking for recommendations on a restaurant resource.

The restaurant "show" page should display the name of the restaurant, a description of the restaurant paragraph, 3-5 photos, some descriptive tags, and a complete menu with dish names and prices. How should I attack this database problem? I am considering creating three models, for example:

class Restaurant < ActiveRecord::Base
 has_many :dishes, :through => :menus
end

class Menu < ActiveRecord::Base
 belongs_to :restaurant
end

class Dish < ActiveRecord::Base
 belongs_to :menu
 has_one :restaurant, :through :menus
end

      

Is this the correct approach?

I have two problems:

1) The string attribute in the database is limited to 255 characters, which is not enough to store a restaurant description. How can I proceed here? I would like the description to be edited by admin.

2) How to process pictures? I did some searching and some people suggested CarrierWave for downloading apps. Does anyone have any other suggestions or alternatives? These photos should be easily modified by the administrator and they should belong to the restaurant.

Thank you for your help.

+3


source to share


1 answer


Yes, this is a great way to do it.

To store more text in a database table field, use "text" as follows:

create_table :products do |t|
  t.string :name
  t.text :description
end

      



Yes, choose CarrierWave. Some alternatives:

  • Paperclip (not bad)
  • Rolling your own (bad idea if you don't like learning)
  • various JavaScript / jQuery / AJAX load helpers (really slippery, but more complex).
+2


source







All Articles