| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://coffeescript.org/ | |||||
| @@ -0,0 +1,48 @@ | |||||
| // Place all the styles related to the Store controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| .store { | |||||
| h1 { | |||||
| margin: 0; | |||||
| padding-bottom: 0.5em; | |||||
| font: 150% sans-serif; | |||||
| color: #226; | |||||
| border-bottom: 3px dotted #77d; | |||||
| } | |||||
| .entry { | |||||
| overflow: auto; | |||||
| margin-top: 1em; | |||||
| border-bottom: 1px dotted #77d; | |||||
| min-height: 100px; | |||||
| img { | |||||
| width: 80px; | |||||
| margin-right: 5px; | |||||
| margin-bottom: 5px; | |||||
| position: absolute; | |||||
| } | |||||
| h3 { | |||||
| font-size: 120%; | |||||
| font-family: sans-serif; | |||||
| margin-left: 100px; | |||||
| margin-top: 0; | |||||
| margin-bottom: 2px; | |||||
| color: #227 | |||||
| } | |||||
| p, div.price_line { | |||||
| margin-left: 100px; | |||||
| margin-top: 0.5em; | |||||
| margin-bottom: 0.8em; | |||||
| } | |||||
| .price { | |||||
| color: #44a; | |||||
| font-weight: bold; | |||||
| margin-right: 3em; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,5 @@ | |||||
| class StoreController < ApplicationController | |||||
| def index | |||||
| @products = Product.order(:title) | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| module StoreHelper | |||||
| end | |||||
| @@ -0,0 +1,14 @@ | |||||
| <p id="notice"><%= notice %></p> | |||||
| <h1>Your Pragmatic Catalog</h1> | |||||
| <% @products.each do |product| %> | |||||
| <div class="entry"> | |||||
| <%= image_tag(product.image_url) %> | |||||
| <h3><%= product.title %></h3> | |||||
| <%= sanitize(product.description) %> | |||||
| <div class="price_line"> | |||||
| <span class="price"><%= product.price %></span> | |||||
| </div> | |||||
| </div> | |||||
| <% end %> | |||||
| @@ -1,4 +1,6 @@ | |||||
| Rails.application.routes.draw do | Rails.application.routes.draw do | ||||
| root 'store#index', as: 'store_index' | |||||
| resources :products | resources :products | ||||
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||||
| end | end | ||||
| @@ -0,0 +1,9 @@ | |||||
| require 'test_helper' | |||||
| class StoreControllerTest < ActionDispatch::IntegrationTest | |||||
| test "should get index" do | |||||
| get store_index_url | |||||
| assert_response :success | |||||
| end | |||||
| end | |||||