瀏覽代碼

Iteration C1.

master
Nils Dittberner 9 年之前
父節點
當前提交
0362b080c0
共有 7 個文件被更改,包括 83 次插入0 次删除
  1. +3
    -0
      app/assets/javascripts/store.coffee
  2. +48
    -0
      app/assets/stylesheets/store.scss
  3. +5
    -0
      app/controllers/store_controller.rb
  4. +2
    -0
      app/helpers/store_helper.rb
  5. +14
    -0
      app/views/store/index.html.erb
  6. +2
    -0
      config/routes.rb
  7. +9
    -0
      test/controllers/store_controller_test.rb

+ 3
- 0
app/assets/javascripts/store.coffee 查看文件

@@ -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/

+ 48
- 0
app/assets/stylesheets/store.scss 查看文件

@@ -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;
}
}
}

+ 5
- 0
app/controllers/store_controller.rb 查看文件

@@ -0,0 +1,5 @@
class StoreController < ApplicationController
def index
@products = Product.order(:title)
end
end

+ 2
- 0
app/helpers/store_helper.rb 查看文件

@@ -0,0 +1,2 @@
module StoreHelper
end

+ 14
- 0
app/views/store/index.html.erb 查看文件

@@ -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 %>

+ 2
- 0
config/routes.rb 查看文件

@@ -1,4 +1,6 @@
Rails.application.routes.draw do
root 'store#index', as: 'store_index'

resources :products
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

+ 9
- 0
test/controllers/store_controller_test.rb 查看文件

@@ -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

Loading…
取消
儲存