#Store products.
- gem install rails
- rails new Rails-Store
- cd Rails-Store
Structure
├── app
│ ├── assets
│ │ ├── images
│ │ ├── javascripts
│ │ └── stylesheets
│ ├── controllers
│ │ └── concerns
│ ├── helpers
│ ├── mailers
│ ├── models
│ │ └── concerns
│ └── views
│ └── layouts
├── bin
├── config
│ ├── environments
│ ├── initializers
│ └── locales
├── db
├── lib
│ ├── assets
│ └── tasks
├── log
├── public
├── test
│ ├── controllers
│ ├── fixtures
│ ├── helpers
│ ├── integration
│ ├── mailers
│ └── models
├── tmp
│ └── cache
│ └── assets
└── vendor
└── assets
├── javascripts
└── stylesheets
Adding Users Authentication with Devise Module Device install command
- rails g migration users name:string tel:string address:string email:string:uniq level:integer
- rails g model newsletters body:text date_newsletter:datetime nb_email:string
- rails g model orders order_date:datetime user_id:integer
- rails g model order_product order_id:integer product_id:integer quantity:integer
- rails g model products name:string margin_product:decimal 'price:decimal{5,2}'
- rails g model recipes product_id:integer ingredient_id:integer
- rails g model ingredients name:string
- rails g model ingredients_history ingredient_id:integer 'price_ingredient:decimal{5,2}' year:integer
In Rails, an association is a connection between two Active Record models. Associations are implemented using macro-style calls, so that you can declaratively add features to your models. For example, by declaring that one model belongs_to another, you instruct Rails to maintain Primary Key–Foreign Key information between instances of the two models, and you also get a number of utility methods added to your model. Rails supports six types of associations:
belongs_to
has_one
has_many
has_many :through
has_one :through
has_and_belongs_to_many
rake db:migrate