bread 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -4
  3. data/Rakefile +15 -19
  4. data/lib/bread/controller.rb +26 -0
  5. data/lib/bread/manager/actions.rb +1 -21
  6. data/lib/bread/manager/crumbs.rb +1 -16
  7. data/lib/bread/reloader.rb +30 -0
  8. data/lib/bread/version.rb +1 -1
  9. data/lib/bread.rb +12 -1
  10. data/lib/generators/bread/install_generator.rb +17 -2
  11. data/{test/dummy/app/lib → lib/generators/bread/templates}/bread/actions.rb +18 -18
  12. data/lib/generators/bread/templates/bread/crumbs.rb +20 -0
  13. data/lib/generators/bread/templates/view.html.erb +9 -0
  14. data/spec/controllers/photos_controller_spec.rb +94 -0
  15. data/spec/controllers/products_controller_spec.rb +94 -0
  16. data/{test → spec}/dummy/README.rdoc +0 -0
  17. data/{test → spec}/dummy/Rakefile +0 -0
  18. data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
  19. data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
  20. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  21. data/spec/dummy/app/controllers/photos_controller.rb +96 -0
  22. data/spec/dummy/app/controllers/products_controller.rb +98 -0
  23. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  24. data/spec/dummy/app/lib/bread/actions.rb +18 -0
  25. data/{test → spec}/dummy/app/lib/bread/crumbs.rb +26 -25
  26. data/spec/dummy/app/models/category.rb +7 -0
  27. data/spec/dummy/app/models/photo.rb +11 -0
  28. data/spec/dummy/app/models/product.rb +12 -0
  29. data/spec/dummy/app/views/layouts/application.html.erb +23 -0
  30. data/spec/dummy/app/views/photos/_form.html.erb +21 -0
  31. data/spec/dummy/app/views/photos/edit.html.erb +6 -0
  32. data/spec/dummy/app/views/photos/index.html.erb +25 -0
  33. data/spec/dummy/app/views/photos/new.html.erb +5 -0
  34. data/spec/dummy/app/views/photos/show.html.erb +9 -0
  35. data/{test → spec}/dummy/app/views/products/_form.html.erb +4 -4
  36. data/{test → spec}/dummy/app/views/products/edit.html.erb +0 -0
  37. data/{test → spec}/dummy/app/views/products/index.html.erb +1 -3
  38. data/{test → spec}/dummy/app/views/products/new.html.erb +0 -0
  39. data/{test → spec}/dummy/app/views/products/show.html.erb +0 -0
  40. data/{test → spec}/dummy/bin/bundle +0 -0
  41. data/{test → spec}/dummy/bin/rails +0 -0
  42. data/{test → spec}/dummy/bin/rake +0 -0
  43. data/{test → spec}/dummy/config/application.rb +8 -0
  44. data/{test → spec}/dummy/config/boot.rb +0 -0
  45. data/{test → spec}/dummy/config/database.yml +1 -3
  46. data/{test → spec}/dummy/config/environment.rb +0 -0
  47. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  48. data/{test → spec}/dummy/config/environments/production.rb +0 -0
  49. data/{test → spec}/dummy/config/environments/test.rb +0 -1
  50. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  51. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  52. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  53. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  54. data/{test → spec}/dummy/config/initializers/secret_token.rb +1 -1
  55. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  56. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  57. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  58. data/{test → spec}/dummy/config/routes.rb +1 -3
  59. data/{test → spec}/dummy/config.ru +0 -0
  60. data/{test → spec}/dummy/db/development.sqlite3 +0 -0
  61. data/spec/dummy/db/migrate/20140912040816_create_foos.rb +9 -0
  62. data/spec/dummy/db/migrate/20140912042735_create_admin_foos.rb +9 -0
  63. data/{test/dummy/db/migrate/20140203163238_create_products.rb → spec/dummy/db/migrate/20150312182743_create_products.rb} +1 -1
  64. data/spec/dummy/db/migrate/20150312182826_create_categories.rb +9 -0
  65. data/spec/dummy/db/migrate/20150312183119_create_photos.rb +10 -0
  66. data/{test/dummy/app/controllers/concerns/.keep → spec/dummy/db/production.sqlite3} +0 -0
  67. data/{test → spec}/dummy/db/schema.rb +22 -21
  68. data/{test → spec}/dummy/db/test.sqlite3 +0 -0
  69. data/spec/dummy/lib/templates/rails/scaffold_controller/controller.rb +101 -0
  70. data/spec/dummy/log/development.log +167 -0
  71. data/spec/dummy/log/production.log +66 -0
  72. data/spec/dummy/log/test.log +21931 -0
  73. data/{test → spec}/dummy/public/404.html +0 -0
  74. data/{test → spec}/dummy/public/422.html +0 -0
  75. data/{test → spec}/dummy/public/500.html +0 -0
  76. data/{test → spec}/dummy/public/favicon.ico +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  83. data/spec/rails_helper.rb +78 -0
  84. data/spec/requests/photos_spec.rb +12 -0
  85. data/spec/requests/products_spec.rb +11 -0
  86. data/spec/spec_helper.rb +85 -0
  87. data/spec/support/bread_spec_controller_methods.rb +11 -0
  88. data/spec/support/controllers/bread_spec_controller_methods.rb +12 -0
  89. metadata +254 -193
  90. data/.gitignore +0 -22
  91. data/Gemfile +0 -26
  92. data/LICENSE.txt +0 -22
  93. data/bread.gemspec +0 -24
  94. data/lib/bread/helper.rb +0 -16
  95. data/lib/generators/bread/templates/skeleton.rb +0 -12
  96. data/test/dummy/app/assets/javascripts/product_photos.js +0 -2
  97. data/test/dummy/app/assets/javascripts/products.js +0 -2
  98. data/test/dummy/app/assets/stylesheets/product_photos.css +0 -4
  99. data/test/dummy/app/assets/stylesheets/products.css +0 -4
  100. data/test/dummy/app/assets/stylesheets/scaffold.css +0 -56
  101. data/test/dummy/app/controllers/product_photos_controller.rb +0 -63
  102. data/test/dummy/app/controllers/products_controller.rb +0 -72
  103. data/test/dummy/app/helpers/product_photos_helper.rb +0 -2
  104. data/test/dummy/app/helpers/products_helper.rb +0 -2
  105. data/test/dummy/app/lib/bread/actions_next.rb +0 -43
  106. data/test/dummy/app/lib/bread/crumbs_next.rb +0 -77
  107. data/test/dummy/app/mailers/.keep +0 -0
  108. data/test/dummy/app/models/.keep +0 -0
  109. data/test/dummy/app/models/concerns/.keep +0 -0
  110. data/test/dummy/app/models/product.rb +0 -10
  111. data/test/dummy/app/models/product_photo.rb +0 -10
  112. data/test/dummy/app/models/user.rb +0 -6
  113. data/test/dummy/app/views/layouts/application.html.erb +0 -34
  114. data/test/dummy/app/views/product_photos/_form.html.erb +0 -25
  115. data/test/dummy/app/views/product_photos/edit.html.erb +0 -6
  116. data/test/dummy/app/views/product_photos/index.html.erb +0 -31
  117. data/test/dummy/app/views/product_photos/new.html.erb +0 -5
  118. data/test/dummy/app/views/product_photos/show.html.erb +0 -19
  119. data/test/dummy/config/breadcrumbs.rb +0 -18
  120. data/test/dummy/config/initializers/devise.rb +0 -254
  121. data/test/dummy/config/locales/devise.en.yml +0 -59
  122. data/test/dummy/db/migrate/20140306111733_devise_create_users.rb +0 -42
  123. data/test/dummy/db/migrate/20140306114935_create_product_photos.rb +0 -11
  124. data/test/dummy/lib/assets/.keep +0 -0
  125. data/test/dummy/lib/templates/rails/scaffold_controller/controller.rb +0 -146
  126. data/test/dummy/log/.keep +0 -0
  127. data/test/dummy/test/bread_test.rb +0 -7
  128. data/test/dummy/test/controllers/product_photos_controller_test.rb +0 -98
  129. data/test/dummy/test/controllers/products_controller_test.rb +0 -114
  130. data/test/dummy/test/fixtures/product_photos.yml +0 -11
  131. data/test/dummy/test/fixtures/products.yml +0 -9
  132. data/test/dummy/test/fixtures/users.yml +0 -11
  133. data/test/dummy/test/helpers/product_photos_helper_test.rb +0 -4
  134. data/test/dummy/test/helpers/products_helper_test.rb +0 -4
  135. data/test/dummy/test/integration/devise_test.rb +0 -166
  136. data/test/dummy/test/integration/navigation_test.rb +0 -10
  137. data/test/dummy/test/models/product_photo_test.rb +0 -7
  138. data/test/dummy/test/models/product_test.rb +0 -7
  139. data/test/dummy/test/models/user_test.rb +0 -7
  140. data/test/dummy/test/support/asserts.rb +0 -38
  141. data/test/dummy/test/support/others.rb +0 -20
  142. data/test/test_helper.rb +0 -21
@@ -0,0 +1,98 @@
1
+
2
+
3
+ class ProductsController < ApplicationController
4
+
5
+ # Use callbacks to share common setup or constraints between actions.
6
+ before_actions do
7
+ # all { } # pre-fetching authorization step
8
+ # all { } # load your nested resource's parent here
9
+ only(:index) { @products = Product.all }
10
+ only(:new) { @product = Product.new }
11
+ only(:create) { @product = Product.new(product_params) }
12
+ only(:show, :edit, :update, :destroy) { @product = Product.find(params[:id]) }
13
+ # all { } # post-fetching authorization step
14
+ end
15
+
16
+ # GET /products
17
+ # GET /products.json
18
+ def index
19
+ respond_to do |format|
20
+ format.html # index.html.erb
21
+ format.json { render json: @products }
22
+ end
23
+ end
24
+
25
+
26
+
27
+
28
+ # GET /products/new
29
+ def new
30
+ end
31
+
32
+ # POST /products
33
+ # POST /products.json
34
+ def create
35
+ respond_to do |format|
36
+ if @product.save
37
+ format.html { redirect_to @product, notice: 'Product was successfully created.' }
38
+ format.json { render json: @product, status: :created }
39
+ else
40
+ format.html { render action: 'new' }
41
+ format.json { render json: @product.errors, status: :unprocessable_entity }
42
+ end
43
+ end
44
+ end
45
+
46
+
47
+
48
+
49
+
50
+ # GET /products/1
51
+ # GET /products/1.json
52
+ def show
53
+ respond_to do |format|
54
+ format.html # show.html.erb
55
+ format.json { render json: @product }
56
+ end
57
+ end
58
+
59
+ # GET /products/1/edit
60
+ def edit
61
+ end
62
+
63
+ # PATCH/PUT /products/1
64
+ # PATCH/PUT /products/1.json
65
+ def update
66
+ respond_to do |format|
67
+ if @product.update(product_params)
68
+ format.html { redirect_to @product, notice: 'Product was successfully updated.' }
69
+ format.json { head :no_content }
70
+ else
71
+ format.html { render action: 'edit' }
72
+ format.json { render json: @product.errors, status: :unprocessable_entity }
73
+ end
74
+ end
75
+ end
76
+
77
+ # DELETE /products/1
78
+ # DELETE /products/1
79
+ def destroy
80
+ respond_to do |format|
81
+ if @product.destroy
82
+ format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
83
+ format.json { head :no_content }
84
+ else
85
+ format.html { render action: 'edit' }
86
+ format.json { render json: @product.errors, status: :unprocessable_entity }
87
+ end
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ # Only allow a trusted parameter "white list" through.
94
+ def product_params
95
+ params.require(:product).permit(:name, :category_id)
96
+ end
97
+ end
98
+
@@ -0,0 +1,18 @@
1
+ Bread.actions.config do
2
+
3
+ controller :products, parent_crumbs: [:@root] do
4
+ actions(:index) { crumbs :@products }
5
+ actions(:new) { crumbs :@products, :@new_product }
6
+ actions(:by_category) { crumbs :@products, :@products_by_category }
7
+ actions(:show) { crumbs :@products, :@product }
8
+ actions(:edit) { crumbs :@products, :@product, :@edit_product }
9
+ end
10
+
11
+ controller :photos, parent_crumbs: [:@root, :@products, :@product] do
12
+ actions(:index) { crumbs :@photos }
13
+ actions(:new) { crumbs :@photos, :@new_photo }
14
+ actions(:show) { crumbs :@photos, :@photo }
15
+ actions(:edit) { crumbs :@photos, :@photo, :@edit_photo }
16
+ end
17
+
18
+ end
@@ -1,25 +1,26 @@
1
- Bread.crumbs.config do
2
-
3
- crumb(:@root) { to "Home", :root, icon: 'home' }
4
-
5
- # products
6
- crumb(:@products) { to "Products", h.products_path }
7
- crumb(:@new_product) { to "New", h.new_product_path }
8
- crumb(:@edit_product) { to "Edit", h.edit_product_path }
9
- crumb(:@products_by_category) { to @category, h.by_category_products_path(@category) }
10
- crumb(:@product) {
11
- cat = @product.category
12
- to cat, h.by_category_products_path(category: cat) if !cat.blank?
13
- to @product.unchanged_name, h.product_path(@product)
14
- }
15
-
16
- # photos
17
- crumb(:@photos) { to "Photos", h.product_product_photos_path }
18
- crumb(:@new_photo) { to "New", h.new_product_product_photo_path }
19
- crumb(:@edit_photo) { to "Edit", h.edit_product_product_photo_path }
20
- crumb(:@photo) { to @product_photo.unchanged_name, h.product_product_photo_path }
21
-
22
-
23
-
24
-
25
- end
1
+ Bread.crumbs.config do
2
+
3
+ crumb(:@root) { to "Home", :root, icon: 'home' }
4
+
5
+ # products
6
+ crumb(:@products) { to "Products", h.products_path }
7
+ crumb(:@new_product) { to "New", h.new_product_path }
8
+ crumb(:@edit_product) { to "Edit", h.edit_product_path }
9
+ crumb(:@products_by_category) { to @category, h.by_category_products_path(@category) }
10
+ crumb(:@product) {
11
+ cat = @product.category
12
+ to cat, h.by_category_products_path(category: cat) if !cat.blank?
13
+ to @product.name, h.product_path(@product)
14
+ }
15
+
16
+ # photos
17
+ crumb(:@photos) { to "Photos", h.product_photos_path }
18
+ crumb(:@new_photo) { to "New", h.new_product_photo_path }
19
+ crumb(:@edit_photo) { to "Edit", h.edit_product_photo_path }
20
+ crumb(:@photo) { to @photo.name, h.product_photo_path }
21
+
22
+
23
+
24
+
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ class Category < ActiveRecord::Base
2
+
3
+ # for testing purposes this app does not permit destroying it's models
4
+ before_destroy do
5
+ false
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ class Photo < ActiveRecord::Base
2
+ belongs_to :product
3
+
4
+ validates_presence_of :name
5
+ validates_length_of :name, minimum: 3
6
+
7
+ # for testing purposes this app does not permit destroying it's models
8
+ before_destroy do
9
+ false
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class Product < ActiveRecord::Base
2
+ belongs_to :category
3
+ has_many :photos
4
+
5
+ validates_presence_of :name
6
+ validates_length_of :name, minimum: 3
7
+
8
+ # for testing purposes this app does not permit destroying it's models
9
+ before_destroy do
10
+ false
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <ul id="breadcrumbs">
12
+ <% bread.each do |crumb| %>
13
+ <li class="<%= 'active' if crumb.current? %>">
14
+ <%= link_to crumb.title, crumb.path, class: "icon icon-#{crumb[:icon]}" %>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+
19
+
20
+ <%= yield %>
21
+
22
+ </body>
23
+ </html>
@@ -0,0 +1,21 @@
1
+ <%= form_for([product, @photo]) do |f| %>
2
+ <% if @photo.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@photo.errors.count, "error") %> prohibited this photo from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @photo.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :product_id %><br>
16
+ <%= f.text_field :product_id %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing photo</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', [@product, @photo] %> |
6
+ <%= link_to 'Back', product_photos_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing photos</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Product</th>
7
+ <th colspan="3"></th>
8
+ </tr>
9
+ </thead>
10
+
11
+ <tbody>
12
+ <% @photos.each do |photo| %>
13
+ <tr>
14
+ <td><%= photo.product %></td>
15
+ <td><%= link_to 'Show', [product, photo] %></td>
16
+ <td><%= link_to 'Edit', edit_product_photo_path(@product, photo) %></td>
17
+ <td><%= link_to 'Destroy', [product, photo], method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
+ </tr>
19
+ <% end %>
20
+ </tbody>
21
+ </table>
22
+
23
+ <br>
24
+
25
+ <%= link_to 'New Photo', new_product_photo_path(@product) %>
@@ -0,0 +1,5 @@
1
+ <h1>New photo</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', photos_path %>
@@ -0,0 +1,9 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Product:</strong>
5
+ <%= @photo.product %>
6
+ </p>
7
+
8
+ <%= link_to 'Edit', edit_product_photo_path([@product, @photo]) %> |
9
+ <%= link_to 'Back', product_photos_path %>
@@ -4,8 +4,8 @@
4
4
  <h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
5
5
 
6
6
  <ul>
7
- <% @product.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
7
+ <% @product.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
9
  <% end %>
10
10
  </ul>
11
11
  </div>
@@ -16,8 +16,8 @@
16
16
  <%= f.text_field :name %>
17
17
  </div>
18
18
  <div class="field">
19
- <%= f.label :category %><br>
20
- <%= f.text_field :category %>
19
+ <%= f.label :category_id %><br>
20
+ <%= f.text_field :category_id %>
21
21
  </div>
22
22
  <div class="actions">
23
23
  <%= f.submit %>
@@ -5,9 +5,7 @@
5
5
  <tr>
6
6
  <th>Name</th>
7
7
  <th>Category</th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
8
+ <th colspan="3"></th>
11
9
  </tr>
12
10
  </thead>
13
11
 
File without changes
File without changes
File without changes
@@ -18,6 +18,14 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
+
22
+ # don't generate RSpec tests for views and helpers
23
+ config.generators do |g|
24
+ g.test_framework :rspec
25
+ g.stylesheets = false
26
+ g.javascripts = false
27
+ g.helper = false
28
+ end
21
29
  end
22
30
  end
23
31
 
File without changes
@@ -14,9 +14,7 @@ development:
14
14
  # Do not set this db to the same as development or production.
15
15
  test:
16
16
  adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
17
+ database: ":memory:"
20
18
 
21
19
  production:
22
20
  adapter: sqlite3
File without changes
@@ -30,7 +30,6 @@ Dummy::Application.configure do
30
30
  # The :test delivery method accumulates sent emails in the
31
31
  # ActionMailer::Base.deliveries array.
32
32
  config.action_mailer.delivery_method = :test
33
- config.action_mailer.default_url_options = {host: 'example.com'}
34
33
 
35
34
  # Print deprecation notices to the stderr.
36
35
  config.active_support.deprecation = :stderr
@@ -9,4 +9,4 @@
9
9
 
10
10
  # Make sure your secret_key_base is kept private
11
11
  # if you're sharing your code publicly.
12
- Dummy::Application.config.secret_key_base = '60ebd718b90e9969d33b9b85470157230b42e9d7a4e5b1151b383b3b851cb15721f93cbffc84c34e93b7b4d04d019fa95cb3cd8f3c87d63d372d808b3a6ac46e'
12
+ Dummy::Application.config.secret_key_base = 'f8f1cfd724082fee10202ea60f857d16b79a9aa676f85c35e0150f8119fa2da3911c966f051018054f6eaffd8165a1b7e790ff18634e40dbe11f6863fedb5cff'
File without changes
@@ -1,15 +1,13 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- devise_for :users
4
3
  root to: "products#index"
5
4
 
6
5
  resources :products do
7
- resources :product_photos
6
+ resources :photos
8
7
 
9
8
  collection do
10
9
  get 'by_category/:category' => 'products#by_category', as: :by_category
11
10
  end
12
11
  end
13
12
 
14
- #mount Bread::Engine => "/bread"
15
13
  end
File without changes
@@ -0,0 +1,9 @@
1
+ class CreateFoos < ActiveRecord::Migration
2
+ def change
3
+ create_table :foos do |t|
4
+ t.string :bar
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateAdminFoos < ActiveRecord::Migration
2
+ def change
3
+ create_table :admin_foos do |t|
4
+ t.string :bar
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -2,7 +2,7 @@ class CreateProducts < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :products do |t|
4
4
  t.string :name
5
- t.string :category
5
+ t.references :category, index: true
6
6
 
7
7
  t.timestamps
8
8
  end
@@ -0,0 +1,9 @@
1
+ class CreateCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :categories do |t|
4
+ t.string :handle
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreatePhotos < ActiveRecord::Migration
2
+ def change
3
+ create_table :photos do |t|
4
+ t.references :product, index: true
5
+ t.string :name
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -11,41 +11,42 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140306114935) do
14
+ ActiveRecord::Schema.define(version: 20150312183119) do
15
15
 
16
- create_table "product_photos", force: true do |t|
17
- t.integer "product_id"
18
- t.string "name"
19
- t.integer "order", default: 0
16
+ create_table "admin_foos", force: true do |t|
17
+ t.string "bar"
20
18
  t.datetime "created_at"
21
19
  t.datetime "updated_at"
22
20
  end
23
21
 
24
- add_index "product_photos", ["product_id"], name: "index_product_photos_on_product_id"
22
+ create_table "categories", force: true do |t|
23
+ t.string "handle"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
26
+ end
25
27
 
26
- create_table "products", force: true do |t|
28
+ create_table "foos", force: true do |t|
29
+ t.string "bar"
30
+ t.datetime "created_at"
31
+ t.datetime "updated_at"
32
+ end
33
+
34
+ create_table "photos", force: true do |t|
35
+ t.integer "product_id"
27
36
  t.string "name"
28
- t.string "category"
29
37
  t.datetime "created_at"
30
38
  t.datetime "updated_at"
31
39
  end
32
40
 
33
- create_table "users", force: true do |t|
34
- t.string "email", default: "", null: false
35
- t.string "encrypted_password", default: "", null: false
36
- t.string "reset_password_token"
37
- t.datetime "reset_password_sent_at"
38
- t.datetime "remember_created_at"
39
- t.integer "sign_in_count", default: 0, null: false
40
- t.datetime "current_sign_in_at"
41
- t.datetime "last_sign_in_at"
42
- t.string "current_sign_in_ip"
43
- t.string "last_sign_in_ip"
41
+ add_index "photos", ["product_id"], name: "index_photos_on_product_id"
42
+
43
+ create_table "products", force: true do |t|
44
+ t.string "name"
45
+ t.integer "category_id"
44
46
  t.datetime "created_at"
45
47
  t.datetime "updated_at"
46
48
  end
47
49
 
48
- add_index "users", ["email"], name: "index_users_on_email", unique: true
49
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
50
+ add_index "products", ["category_id"], name: "index_products_on_category_id"
50
51
 
51
52
  end
Binary file