cookbook 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +10 -0
  5. data/Gemfile +39 -0
  6. data/Gemfile.lock +367 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +105 -0
  9. data/Rakefile +52 -0
  10. data/VERSION +1 -0
  11. data/app/assets/stylesheets/cookbook/application.scss +180 -0
  12. data/app/controllers/concerns/cookbook/params.rb +27 -0
  13. data/app/helpers/cookbook/application_helper.rb +38 -0
  14. data/app/models/cookbook/use.rb +26 -0
  15. data/app/views/cookbook/_fields.html.haml +11 -0
  16. data/app/views/cookbook/_used_in.html.haml +15 -0
  17. data/app/views/cookbook/_uses_of.html.haml +11 -0
  18. data/app/views/cookbook/uses/_fields.html.haml +17 -0
  19. data/bin/rails +16 -0
  20. data/config/initializers/simple_form.rb +180 -0
  21. data/config/locales/simple_form.en.yml +31 -0
  22. data/cookbook.gemspec +249 -0
  23. data/db/migrate/20210909141929_create_uses.cookbook.rb +21 -0
  24. data/lib/cookbook/configuration.rb +28 -0
  25. data/lib/cookbook/engine.rb +34 -0
  26. data/lib/cookbook/extensions/float.rb +10 -0
  27. data/lib/cookbook/mixins/acts_as_use_of.rb +45 -0
  28. data/lib/cookbook/mixins/acts_as_used_in.rb +43 -0
  29. data/lib/cookbook/railtie.rb +6 -0
  30. data/lib/cookbook/version.rb +9 -0
  31. data/lib/cookbook.rb +27 -0
  32. data/lib/tasks/cookbook_tasks.rake +5 -0
  33. data/lib/templates/haml/scaffold/_form.html.haml +12 -0
  34. data/spec/cookbook_spec.rb +9 -0
  35. data/spec/dummy/Rakefile +8 -0
  36. data/spec/dummy/app/assets/config/manifest.js +2 -0
  37. data/spec/dummy/app/assets/images/.keep +0 -0
  38. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  39. data/spec/dummy/app/assets/stylesheets/scaffolds.scss +65 -0
  40. data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
  41. data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  43. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  44. data/spec/dummy/app/controllers/how_tos_controller.rb +61 -0
  45. data/spec/dummy/app/controllers/ingredients_controller.rb +60 -0
  46. data/spec/dummy/app/controllers/recipes_controller.rb +61 -0
  47. data/spec/dummy/app/controllers/supplies_controller.rb +60 -0
  48. data/spec/dummy/app/controllers/tools_controller.rb +60 -0
  49. data/spec/dummy/app/javascript/packs/application.js +16 -0
  50. data/spec/dummy/app/jobs/application_job.rb +9 -0
  51. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  52. data/spec/dummy/app/models/ability.rb +21 -0
  53. data/spec/dummy/app/models/application_record.rb +7 -0
  54. data/spec/dummy/app/models/concerns/.keep +0 -0
  55. data/spec/dummy/app/models/how_to.rb +5 -0
  56. data/spec/dummy/app/models/ingredient.rb +5 -0
  57. data/spec/dummy/app/models/recipe.rb +5 -0
  58. data/spec/dummy/app/models/supply.rb +5 -0
  59. data/spec/dummy/app/models/tool.rb +5 -0
  60. data/spec/dummy/app/models/user.rb +8 -0
  61. data/spec/dummy/app/views/how_tos/_form.html.haml +7 -0
  62. data/spec/dummy/app/views/how_tos/edit.html.haml +7 -0
  63. data/spec/dummy/app/views/how_tos/index.html.haml +25 -0
  64. data/spec/dummy/app/views/how_tos/new.html.haml +5 -0
  65. data/spec/dummy/app/views/how_tos/show.html.haml +17 -0
  66. data/spec/dummy/app/views/ingredients/_form.html.haml +8 -0
  67. data/spec/dummy/app/views/ingredients/edit.html.haml +7 -0
  68. data/spec/dummy/app/views/ingredients/index.html.haml +29 -0
  69. data/spec/dummy/app/views/ingredients/new.html.haml +5 -0
  70. data/spec/dummy/app/views/ingredients/show.html.haml +23 -0
  71. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  72. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  73. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  74. data/spec/dummy/app/views/recipes/_form.html.haml +9 -0
  75. data/spec/dummy/app/views/recipes/edit.html.haml +7 -0
  76. data/spec/dummy/app/views/recipes/index.html.haml +29 -0
  77. data/spec/dummy/app/views/recipes/new.html.haml +5 -0
  78. data/spec/dummy/app/views/recipes/show.html.haml +23 -0
  79. data/spec/dummy/app/views/supplies/_form.html.haml +6 -0
  80. data/spec/dummy/app/views/supplies/edit.html.haml +7 -0
  81. data/spec/dummy/app/views/supplies/index.html.haml +25 -0
  82. data/spec/dummy/app/views/supplies/new.html.haml +5 -0
  83. data/spec/dummy/app/views/supplies/show.html.haml +17 -0
  84. data/spec/dummy/app/views/tools/_form.html.haml +6 -0
  85. data/spec/dummy/app/views/tools/edit.html.haml +7 -0
  86. data/spec/dummy/app/views/tools/index.html.haml +25 -0
  87. data/spec/dummy/app/views/tools/new.html.haml +5 -0
  88. data/spec/dummy/app/views/tools/show.html.haml +17 -0
  89. data/spec/dummy/bin/rails +6 -0
  90. data/spec/dummy/bin/rake +6 -0
  91. data/spec/dummy/bin/setup +35 -0
  92. data/spec/dummy/config/application.rb +28 -0
  93. data/spec/dummy/config/boot.rb +7 -0
  94. data/spec/dummy/config/cable.yml +10 -0
  95. data/spec/dummy/config/database.yml +25 -0
  96. data/spec/dummy/config/environment.rb +7 -0
  97. data/spec/dummy/config/environments/development.rb +80 -0
  98. data/spec/dummy/config/environments/production.rb +122 -0
  99. data/spec/dummy/config/environments/test.rb +61 -0
  100. data/spec/dummy/config/initializers/application_controller_renderer.rb +9 -0
  101. data/spec/dummy/config/initializers/assets.rb +14 -0
  102. data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
  103. data/spec/dummy/config/initializers/content_security_policy.rb +29 -0
  104. data/spec/dummy/config/initializers/cookbook.rb +6 -0
  105. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  106. data/spec/dummy/config/initializers/devise.rb +313 -0
  107. data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  108. data/spec/dummy/config/initializers/inflections.rb +17 -0
  109. data/spec/dummy/config/initializers/json.rb +20 -0
  110. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  111. data/spec/dummy/config/initializers/permissions_policy.rb +12 -0
  112. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  113. data/spec/dummy/config/locales/devise.en.yml +65 -0
  114. data/spec/dummy/config/locales/en.yml +33 -0
  115. data/spec/dummy/config/puma.rb +45 -0
  116. data/spec/dummy/config/routes.rb +13 -0
  117. data/spec/dummy/config/storage.yml +34 -0
  118. data/spec/dummy/config.ru +8 -0
  119. data/spec/dummy/db/development.sqlite3 +0 -0
  120. data/spec/dummy/db/migrate/20210909175711_create_how_tos.rb +16 -0
  121. data/spec/dummy/db/migrate/20210909181442_create_ingredients.rb +16 -0
  122. data/spec/dummy/db/migrate/20210909181455_create_supplies.rb +14 -0
  123. data/spec/dummy/db/migrate/20210909181516_create_tools.rb +14 -0
  124. data/spec/dummy/db/migrate/20210909181533_create_recipes.rb +16 -0
  125. data/spec/dummy/db/migrate/20210909185303_create_uses.cookbook.rb +23 -0
  126. data/spec/dummy/db/migrate/20210910142322_create_users.rb +11 -0
  127. data/spec/dummy/db/migrate/20210910142323_add_devise_to_users.rb +50 -0
  128. data/spec/dummy/db/schema.rb +92 -0
  129. data/spec/dummy/db/seeds.rb +10 -0
  130. data/spec/dummy/db/test.sqlite3 +0 -0
  131. data/spec/dummy/lib/assets/.keep +0 -0
  132. data/spec/dummy/lib/templates/haml/scaffold/_form.html.haml +6 -0
  133. data/spec/dummy/log/.keep +0 -0
  134. data/spec/dummy/log/development.log +6643 -0
  135. data/spec/dummy/log/test.log +25990 -0
  136. data/spec/dummy/public/404.html +67 -0
  137. data/spec/dummy/public/422.html +67 -0
  138. data/spec/dummy/public/500.html +66 -0
  139. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  140. data/spec/dummy/public/apple-touch-icon.png +0 -0
  141. data/spec/dummy/public/favicon.ico +0 -0
  142. data/spec/dummy/storage/.keep +0 -0
  143. data/spec/factories/how_tos.rb +9 -0
  144. data/spec/factories/ingredients.rb +11 -0
  145. data/spec/factories/recipes.rb +11 -0
  146. data/spec/factories/supplies.rb +9 -0
  147. data/spec/factories/tools.rb +9 -0
  148. data/spec/factories/users.rb +9 -0
  149. data/spec/factories/uses.rb +24 -0
  150. data/spec/helpers/cookbook/application_helper_spec.rb +47 -0
  151. data/spec/models/cookbook/use_spec.rb +82 -0
  152. data/spec/models/how_to_spec.rb +18 -0
  153. data/spec/models/ingredient_spec.rb +15 -0
  154. data/spec/models/recipe_spec.rb +18 -0
  155. data/spec/models/supply_spec.rb +15 -0
  156. data/spec/models/tool_spec.rb +15 -0
  157. data/spec/rails_helper.rb +92 -0
  158. data/spec/requests/how_tos_spec.rb +114 -0
  159. data/spec/requests/recipes_spec.rb +116 -0
  160. data/spec/spec_helper.rb +44 -0
  161. metadata +517 -0
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Configure sensitive parameters which will be filtered from the log file.
6
+ Rails.application.config.filter_parameters += %i[
7
+ passw secret token _key crypt salt certificate otp ssn
8
+ ]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new inflection rules using the following format. Inflections
5
+ # are locale specific, and you may define rules for as many different
6
+ # locales as you wish. All of these examples are active by default:
7
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
8
+ # inflect.plural /^(ox)$/i, '\1en'
9
+ # inflect.singular /^(ox)en/i, '\1'
10
+ # inflect.irregular 'person', 'people'
11
+ # inflect.uncountable %w( fish sheep )
12
+ # end
13
+
14
+ # These inflection rules are supported but not enabled by default:
15
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
16
+ # inflect.acronym 'RESTful'
17
+ # end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Was getting lots of errors like this:
4
+ #
5
+ # ~/.rvm/gems/ruby-2.7.2@cookbook/gems/json-1.8.6/lib/json/common.rb:155:
6
+ # warning: Using the last argument as keyword parameters is deprecated
7
+ #
8
+ # Found here: https://github.com/flori/json/issues/399
9
+ # "Using Rails, this seems to get rid of the warnings:"
10
+
11
+ # config/initializers/json.rb
12
+ module JSON
13
+ module_function
14
+
15
+ # :nocov:
16
+ def parse(source, opts = {})
17
+ Parser.new(source, **opts).parse
18
+ end
19
+ # :nocov:
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new mime types for use in respond_to blocks:
5
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # Define an application-wide HTTP permissions policy. For further
3
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
4
+ #
5
+ # Rails.application.config.permissions_policy do |f|
6
+ # f.camera :none
7
+ # f.gyroscope :none
8
+ # f.microphone :none
9
+ # f.usb :none
10
+ # f.fullscreen :self
11
+ # f.payment :self, "https://secure.example.com"
12
+ # end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # This file contains settings for ActionController::ParamsWrapper which
6
+ # is enabled by default.
7
+
8
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9
+ ActiveSupport.on_load(:action_controller) do
10
+ wrap_parameters format: [:json]
11
+ end
12
+
13
+ # To enable root element in JSON for ActiveRecord objects.
14
+ # ActiveSupport.on_load(:active_record) do
15
+ # self.include_root_in_json = true
16
+ # end
@@ -0,0 +1,65 @@
1
+ # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid %{authentication_keys} or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ email_changed:
27
+ subject: "Email Changed"
28
+ password_change:
29
+ subject: "Password Changed"
30
+ omniauth_callbacks:
31
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32
+ success: "Successfully authenticated from %{kind} account."
33
+ passwords:
34
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
37
+ updated: "Your password has been changed successfully. You are now signed in."
38
+ updated_not_active: "Your password has been changed successfully."
39
+ registrations:
40
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41
+ signed_up: "Welcome! You have signed up successfully."
42
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46
+ updated: "Your account has been updated successfully."
47
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
48
+ sessions:
49
+ signed_in: "Signed in successfully."
50
+ signed_out: "Signed out successfully."
51
+ already_signed_out: "Signed out successfully."
52
+ unlocks:
53
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
54
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
55
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
56
+ errors:
57
+ messages:
58
+ already_confirmed: "was already confirmed, please try signing in"
59
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
60
+ expired: "has expired, please request a new one"
61
+ not_found: "not found"
62
+ not_locked: "was not locked"
63
+ not_saved:
64
+ one: "1 error prohibited this %{resource} from being saved:"
65
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Puma can serve each request in a thread from an internal thread pool.
4
+ # The `threads` method setting takes two numbers: a minimum and maximum.
5
+ # Any libraries that use thread pools should be configured to match
6
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
7
+ # and maximum; this matches the default thread size of Active Record.
8
+ #
9
+ max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
10
+ min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
11
+ threads min_threads_count, max_threads_count
12
+
13
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
14
+ # terminating a worker in development environments.
15
+ #
16
+ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
17
+
18
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
19
+ #
20
+ port ENV.fetch('PORT', 3000)
21
+
22
+ # Specifies the `environment` that Puma will run in.
23
+ #
24
+ environment ENV.fetch('RAILS_ENV', 'development')
25
+
26
+ # Specifies the `pidfile` that Puma will use.
27
+ pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
28
+
29
+ # Specifies the number of `workers` to boot in clustered mode.
30
+ # Workers are forked web server processes. If using threads and workers together
31
+ # the concurrency of the application would be max `threads` * `workers`.
32
+ # Workers do not work on JRuby or Windows (both of which do not support
33
+ # processes).
34
+ #
35
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
36
+
37
+ # Use the `preload_app!` method when specifying a `workers` number.
38
+ # This directive tells Puma to first boot the application and load code
39
+ # before forking the application. This takes advantage of Copy On Write
40
+ # process behavior so workers use less memory.
41
+ #
42
+ # preload_app!
43
+
44
+ # Allow puma to be restarted by `rails restart` command.
45
+ plugin :tmp_restart
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ devise_for :users
5
+
6
+ resources :ingredients
7
+ resources :supplies
8
+ resources :recipes
9
+ resources :tools
10
+ resources :how_tos
11
+
12
+ root 'recipes#index'
13
+ end
@@ -0,0 +1,34 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require_relative 'config/environment'
6
+
7
+ run Rails.application
8
+ Rails.application.load_server
Binary file
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migration for HowTos, like "How to build a dog house"
4
+ class CreateHowTos < ActiveRecord::Migration[6.1]
5
+ def change
6
+ create_table :how_tos do |t|
7
+ t.string :name
8
+ t.string :slug
9
+ t.text :description
10
+ t.text :instructions
11
+
12
+ t.timestamps
13
+ end
14
+ add_index :how_tos, :slug, unique: true
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migration for Ingredients, like "Mushrooms"
4
+ class CreateIngredients < ActiveRecord::Migration[6.1]
5
+ def change
6
+ create_table :ingredients do |t|
7
+ t.string :name
8
+ t.text :description
9
+ t.string :aisle
10
+ t.string :store
11
+ t.string :cost
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migration for Supplies, like "Twine"
4
+ class CreateSupplies < ActiveRecord::Migration[6.1]
5
+ def change
6
+ create_table :supplies do |t|
7
+ t.string :name
8
+ t.text :description
9
+ t.string :source
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migration for Tools, like "Skillet"
4
+ class CreateTools < ActiveRecord::Migration[6.1]
5
+ def change
6
+ create_table :tools do |t|
7
+ t.string :name
8
+ t.text :description
9
+ t.string :composition
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Migration for Recipes, like "Caprese Salad"
4
+ class CreateRecipes < ActiveRecord::Migration[6.1]
5
+ def change
6
+ create_table :recipes do |t|
7
+ t.string :name
8
+ t.text :description
9
+ t.string :serves
10
+ t.string :meal
11
+ t.text :instructions
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This migration comes from cookbook (originally 20210909141929)
4
+
5
+ # Uses acts as a polymorphic joining table with extras for context
6
+ # For example, a Recipe might "use" Tools, Supplies, and Ingredients.
7
+ class CreateUses < ActiveRecord::Migration[6.1]
8
+ def change
9
+ create_table :cookbook_uses do |t|
10
+ t.boolean :published, default: true
11
+ t.references :use_in, polymorphic: true, null: false
12
+ t.references :use_of, polymorphic: true, null: false
13
+ t.float :quantity_minimum
14
+ t.float :quantity_maximum
15
+ t.string :unit
16
+ t.integer :sort
17
+ t.string :note
18
+ t.string :preparation
19
+
20
+ t.timestamps
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateUsers < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :users do |t|
6
+ t.string :name
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDeviseToUsers < ActiveRecord::Migration[6.1]
4
+ def self.up
5
+ change_table :users do |t|
6
+ ## Database authenticatable
7
+ t.string :email, null: false, default: ''
8
+ t.string :encrypted_password, null: false, default: ''
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+
14
+ ## Rememberable
15
+ t.datetime :remember_created_at
16
+
17
+ ## Trackable
18
+ # t.integer :sign_in_count, default: 0, null: false
19
+ # t.datetime :current_sign_in_at
20
+ # t.datetime :last_sign_in_at
21
+ # t.string :current_sign_in_ip
22
+ # t.string :last_sign_in_ip
23
+
24
+ ## Confirmable
25
+ # t.string :confirmation_token
26
+ # t.datetime :confirmed_at
27
+ # t.datetime :confirmation_sent_at
28
+ # t.string :unconfirmed_email # Only if using reconfirmable
29
+
30
+ ## Lockable
31
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
33
+ # t.datetime :locked_at
34
+
35
+ # Uncomment below if timestamps were not included in your original model.
36
+ # t.timestamps null: false
37
+ end
38
+
39
+ add_index :users, :email, unique: true
40
+ add_index :users, :reset_password_token, unique: true
41
+ # add_index :users, :confirmation_token, unique: true
42
+ # add_index :users, :unlock_token, unique: true
43
+ end
44
+
45
+ def self.down
46
+ # By default, we don't want to make any assumption about how to roll back a migration when your
47
+ # model already existed. Please edit below which fields you would like to remove in this migration.
48
+ raise ActiveRecord::IrreversibleMigration
49
+ end
50
+ end