Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ====================== SETUP PROJECT ====================
- --- Step 1 Ambiente=> terminal
- gem install rails --version=4.2.6
- rails new bscatapp -d mysql
- cd bscatapp/
- sudo service mysql start
- rake db:create
- --- Step 2 Ambiente=> Edición de archivo
- -- Abrir el archivo Gemfile ubicado en la raiz del proyecto y en la linea depues de 'spring', no se olvide de grabar
- # Twitter Bootstrap Fronted Framework Support
- gem 'therubyracer'
- gem 'less-rails'
- gem 'twitter-bootstrap-rails', '<= 3.2.0'
- # Simplified HTML Form Management
- gem 'simple_form'
- # Authentication Support
- gem 'devise'
- gem 'devise-bootstrap-views'
- # Entitites Admin Support
- gem 'rails_admin'
- ====================== DEVELOPING PROJECT ====================
- --- Step 3: Ambiente=> terminal
- bundle
- rails g controller pages index about_us tos faq contact_us
- rails g bootstrap:install static
- rails g simple_form:install —bootstrap
- rails g devise:install
- rails g devise User
- a
- rails g scaffold Category name:string description:text
- rake db:migrate
- rails g bootstrap:themed categories
- a
- rails g scaffold Product name:string description:text category:references
- rake db:migrate
- rails g bootstrap:themed products
- a
- rails g scaffold Person first_name:string last_name:string
- rake db:migrate
- rails g bootstrap:themed people
- a
- rails g scaffold Warehouse name:string location:text
- rake db:migrate
- rails g bootstrap:themed warehouses
- a
- rails g scaffold Inventory warehouse:references product:references stock:integer
- rake db:migrate
- rails g bootstrap:themed inventories
- a
- rake routes
- --- Step 4: Ambiente=> Crear y editar archivo de archivo
- -- Crear los dos siguientes archivos en: proyecto\app\views\layouts
- _menu.html.erb
- _auth.html.erb
- -- Abrir el archivo _menu.html.erb, pegar el siguiente código y grabar:
- <li><%= link_to "Home", pages_index_path %></li>
- <% if current_user %>
- <li><%= link_to "Categories", categories_path %></li>
- <li><%= link_to "Warehouses", warehouses_path %></li>
- <li><%= link_to "Inventories", inventories_path %></li>
- <li><%= link_to "Products", products_path %></li>
- <% end %>
- <li><%= link_to "About us", pages_about_us_path %></li>
- <li><%= link_to "Terms of Services", pages_tos_path %></li>
- <li><%= link_to "FAQ", pages_faq_path %></li>
- <li><%= link_to "Contact Us", pages_contact_us_path %></li>
- -- Abrir el archivo _auth.html.erb, pegar el siguiente código y grabar:
- <p class="navbar-text navbar-right">
- <% if current_user %>
- Signed in as <a href="#" class="navbar-link"> <%= current_user.email %></a>
- <%= link_to 'Sign out', destroy_user_session_path, method: :delete %>
- <% else %>
- <%= link_to 'Sign In', new_user_session_path %> or
- <%= link_to 'Sign Up', new_user_registration_path %>
- <% end %>
- </p>
- -- Abrir el archivo application.html.erb, y buscar las dos veces que se repite lo siguiente
- -Reemplazar:
- <li><%= link_to "Link1", "/path1" %></li>
- <li><%= link_to "Link2", "/path2" %></li>
- <li><%= link_to "Link3", "/path3" %></li>
- -por:
- <%= render 'layouts/menu' %>
- - Encima de la siguiente línea de código agregar:
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
- - Lo siguiente
- <%= render 'layouts/auth' %>
- --- Step 5: Ambiente=> Editar archivos capa models: proyecto\app\models, agregar arriba de "end"
- -\category.rb
- has_many :products
- -\inventory.rb
- belongs_to :warehouse
- belongs_to :product
- -\product.rb
- belongs_to :category
- has_many :inventories
- has_many :warehouses, through: :inventories
- -\warehouse.rb
- has_many :inventories
- has_many :products, through: :inventories
- --- Step 6: Ambiente=> Editar archivos
- -- Abrir el archivo: proyecto\app\views\products\index.html.erb
- -Reemplazar:
- <th><%= model_class.human_attribute_name(:category_id) %></th>
- -Por:
- <th><%= model_class.human_attribute_name(:category_id) %></th>
- <th><%= model_class.human_attribute_name(:warehouses) %></th>
- -Reemplazar:
- <td><%= product.category_id %></td>
- -Por:
- <td><%= product.category.name %></td>
- <td><%= product.warehouses.count %></td>
- -- Abrir el archivo: proyecto\app\views\categories\index.html.erb
- -Reemplazar:
- <th><%= model_class.human_attribute_name(:description) %></th>
- -Por:
- <th><%= model_class.human_attribute_name(:description) %></th>
- <th><%= model_class.human_attribute_name(:products) %></th>
- -Reemplazar:
- <td><%= category.description %></td>
- -Por:
- <td><%= category.description %></td>
- <td><%= category.products.count %></td>
- --- Step 7: Ambiente=> Edición de archivo
- -- Abrir el archivo tu_proyecto\config\routes.rb, ubicarse en la línea 2, no se olvide de grabar
- root 'pages#index'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement