cookbook 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +39 -0
- data/Gemfile.lock +367 -0
- data/LICENSE.txt +20 -0
- data/README.md +105 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/app/assets/stylesheets/cookbook/application.scss +180 -0
- data/app/controllers/concerns/cookbook/params.rb +27 -0
- data/app/helpers/cookbook/application_helper.rb +38 -0
- data/app/models/cookbook/use.rb +26 -0
- data/app/views/cookbook/_fields.html.haml +11 -0
- data/app/views/cookbook/_used_in.html.haml +15 -0
- data/app/views/cookbook/_uses_of.html.haml +11 -0
- data/app/views/cookbook/uses/_fields.html.haml +17 -0
- data/bin/rails +16 -0
- data/config/initializers/simple_form.rb +180 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/cookbook.gemspec +249 -0
- data/db/migrate/20210909141929_create_uses.cookbook.rb +21 -0
- data/lib/cookbook/configuration.rb +28 -0
- data/lib/cookbook/engine.rb +34 -0
- data/lib/cookbook/extensions/float.rb +10 -0
- data/lib/cookbook/mixins/acts_as_use_of.rb +45 -0
- data/lib/cookbook/mixins/acts_as_used_in.rb +43 -0
- data/lib/cookbook/railtie.rb +6 -0
- data/lib/cookbook/version.rb +9 -0
- data/lib/cookbook.rb +27 -0
- data/lib/tasks/cookbook_tasks.rake +5 -0
- data/lib/templates/haml/scaffold/_form.html.haml +12 -0
- data/spec/cookbook_spec.rb +9 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/assets/stylesheets/scaffolds.scss +65 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/how_tos_controller.rb +61 -0
- data/spec/dummy/app/controllers/ingredients_controller.rb +60 -0
- data/spec/dummy/app/controllers/recipes_controller.rb +61 -0
- data/spec/dummy/app/controllers/supplies_controller.rb +60 -0
- data/spec/dummy/app/controllers/tools_controller.rb +60 -0
- data/spec/dummy/app/javascript/packs/application.js +16 -0
- data/spec/dummy/app/jobs/application_job.rb +9 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/models/ability.rb +21 -0
- data/spec/dummy/app/models/application_record.rb +7 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/how_to.rb +5 -0
- data/spec/dummy/app/models/ingredient.rb +5 -0
- data/spec/dummy/app/models/recipe.rb +5 -0
- data/spec/dummy/app/models/supply.rb +5 -0
- data/spec/dummy/app/models/tool.rb +5 -0
- data/spec/dummy/app/models/user.rb +8 -0
- data/spec/dummy/app/views/how_tos/_form.html.haml +7 -0
- data/spec/dummy/app/views/how_tos/edit.html.haml +7 -0
- data/spec/dummy/app/views/how_tos/index.html.haml +25 -0
- data/spec/dummy/app/views/how_tos/new.html.haml +5 -0
- data/spec/dummy/app/views/how_tos/show.html.haml +17 -0
- data/spec/dummy/app/views/ingredients/_form.html.haml +8 -0
- data/spec/dummy/app/views/ingredients/edit.html.haml +7 -0
- data/spec/dummy/app/views/ingredients/index.html.haml +29 -0
- data/spec/dummy/app/views/ingredients/new.html.haml +5 -0
- data/spec/dummy/app/views/ingredients/show.html.haml +23 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/recipes/_form.html.haml +9 -0
- data/spec/dummy/app/views/recipes/edit.html.haml +7 -0
- data/spec/dummy/app/views/recipes/index.html.haml +29 -0
- data/spec/dummy/app/views/recipes/new.html.haml +5 -0
- data/spec/dummy/app/views/recipes/show.html.haml +23 -0
- data/spec/dummy/app/views/supplies/_form.html.haml +6 -0
- data/spec/dummy/app/views/supplies/edit.html.haml +7 -0
- data/spec/dummy/app/views/supplies/index.html.haml +25 -0
- data/spec/dummy/app/views/supplies/new.html.haml +5 -0
- data/spec/dummy/app/views/supplies/show.html.haml +17 -0
- data/spec/dummy/app/views/tools/_form.html.haml +6 -0
- data/spec/dummy/app/views/tools/edit.html.haml +7 -0
- data/spec/dummy/app/views/tools/index.html.haml +25 -0
- data/spec/dummy/app/views/tools/new.html.haml +5 -0
- data/spec/dummy/app/views/tools/show.html.haml +17 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +35 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +80 -0
- data/spec/dummy/config/environments/production.rb +122 -0
- data/spec/dummy/config/environments/test.rb +61 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +9 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +29 -0
- data/spec/dummy/config/initializers/cookbook.rb +6 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +313 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/json.rb +20 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +12 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/devise.en.yml +65 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +45 -0
- data/spec/dummy/config/routes.rb +13 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +8 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20210909175711_create_how_tos.rb +16 -0
- data/spec/dummy/db/migrate/20210909181442_create_ingredients.rb +16 -0
- data/spec/dummy/db/migrate/20210909181455_create_supplies.rb +14 -0
- data/spec/dummy/db/migrate/20210909181516_create_tools.rb +14 -0
- data/spec/dummy/db/migrate/20210909181533_create_recipes.rb +16 -0
- data/spec/dummy/db/migrate/20210909185303_create_uses.cookbook.rb +23 -0
- data/spec/dummy/db/migrate/20210910142322_create_users.rb +11 -0
- data/spec/dummy/db/migrate/20210910142323_add_devise_to_users.rb +50 -0
- data/spec/dummy/db/schema.rb +92 -0
- data/spec/dummy/db/seeds.rb +10 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/templates/haml/scaffold/_form.html.haml +6 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +6643 -0
- data/spec/dummy/log/test.log +25990 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/factories/how_tos.rb +9 -0
- data/spec/factories/ingredients.rb +11 -0
- data/spec/factories/recipes.rb +11 -0
- data/spec/factories/supplies.rb +9 -0
- data/spec/factories/tools.rb +9 -0
- data/spec/factories/users.rb +9 -0
- data/spec/factories/uses.rb +24 -0
- data/spec/helpers/cookbook/application_helper_spec.rb +47 -0
- data/spec/models/cookbook/use_spec.rb +82 -0
- data/spec/models/how_to_spec.rb +18 -0
- data/spec/models/ingredient_spec.rb +15 -0
- data/spec/models/recipe_spec.rb +18 -0
- data/spec/models/supply_spec.rb +15 -0
- data/spec/models/tool_spec.rb +15 -0
- data/spec/rails_helper.rb +92 -0
- data/spec/requests/how_tos_spec.rb +114 -0
- data/spec/requests/recipes_spec.rb +116 -0
- data/spec/spec_helper.rb +44 -0
- metadata +517 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Uses acts as a polymorphic joining table with extras for context
|
4
|
+
# For example, a Recipe might "use" Tools, Supplies, and Ingredients.
|
5
|
+
class CreateUses < ActiveRecord::Migration[6.1]
|
6
|
+
def change
|
7
|
+
create_table :cookbook_uses do |t|
|
8
|
+
t.boolean :published, default: true
|
9
|
+
t.references :use_in, polymorphic: true, null: false
|
10
|
+
t.references :use_of, polymorphic: true, null: false
|
11
|
+
t.float :quantity_minimum
|
12
|
+
t.float :quantity_maximum
|
13
|
+
t.string :unit
|
14
|
+
t.integer :sort
|
15
|
+
t.string :note
|
16
|
+
t.string :preparation
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Cookbook Module
|
4
|
+
module Cookbook
|
5
|
+
class << self
|
6
|
+
def configure(configuration = Cookbook::Configuration.new)
|
7
|
+
block_given? && yield(configuration)
|
8
|
+
@configuration = configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def configuration
|
12
|
+
@configuration ||= Cookbook::Configuration.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Cookbook Configuration
|
17
|
+
class Configuration
|
18
|
+
attr_accessor(
|
19
|
+
:include_cookbook_css,
|
20
|
+
:authorize_with
|
21
|
+
)
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
self.include_cookbook_css = false
|
25
|
+
self.authorize_with = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cookbook
|
4
|
+
# Cookbook Engine
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
isolate_namespace Cookbook
|
7
|
+
engine_name 'cookbook'
|
8
|
+
|
9
|
+
initializer 'local_helper.action_controller' do
|
10
|
+
ActiveSupport.on_load :action_controller do
|
11
|
+
helper Cookbook::ApplicationHelper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
initializer 'cookbook.assets.precompile' do |app|
|
15
|
+
app.config.assets.precompile += %w[cookbook/application.css cookbook/application.js vanilla_nested.js]
|
16
|
+
end
|
17
|
+
|
18
|
+
config.generators do |g|
|
19
|
+
g.hidden_namespaces << 'test_unit' << 'erb'
|
20
|
+
g.orm :active_record
|
21
|
+
g.template_engine :haml
|
22
|
+
g.test_framework :rspec, fixture: false
|
23
|
+
g.integration_tool :rspec
|
24
|
+
g.stylesheets false
|
25
|
+
g.javascripts false
|
26
|
+
g.view_specs false
|
27
|
+
g.helper_specs false
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.table_name_prefix
|
31
|
+
'cookbook_'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cookbook
|
4
|
+
module Mixins
|
5
|
+
# ActsAsUseIn Mixin, for things like Recipes or HowTos
|
6
|
+
module ActsAsUseOf
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
def acts_as_use_of(*model_symbols)
|
10
|
+
extend ClassMethods
|
11
|
+
include InstanceMethods
|
12
|
+
|
13
|
+
self.used_in = model_symbols
|
14
|
+
|
15
|
+
# Relationships
|
16
|
+
has_many :uses, as: :use_in, class_name: 'Cookbook::Use'
|
17
|
+
associate_used_in
|
18
|
+
end
|
19
|
+
|
20
|
+
# Extended by has_cookbook mixin
|
21
|
+
module ClassMethods
|
22
|
+
attr_accessor(:used_in)
|
23
|
+
|
24
|
+
def associate_used_in
|
25
|
+
used_in.each do |table_sym|
|
26
|
+
model = table_sym.to_s.classify.constantize
|
27
|
+
name = model.model_name.to_s
|
28
|
+
uses_symbol = "#{model.model_name.param_key}_uses".to_sym
|
29
|
+
|
30
|
+
has_many uses_symbol, lambda {
|
31
|
+
where(use_of_type: name)
|
32
|
+
}, as: :use_in, class_name: 'Cookbook::Use'
|
33
|
+
accepts_nested_attributes_for uses_symbol, reject_if: :all_blank, allow_destroy: true
|
34
|
+
|
35
|
+
has_many table_sym, through: :uses, source: :use_of, source_type: name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Included by has_cookbook mixin
|
41
|
+
module InstanceMethods
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cookbook
|
4
|
+
module Mixins
|
5
|
+
# ActsAsUseIn Mixin, for things like Tools, Supplies, or Ingredients
|
6
|
+
module ActsAsUsedIn
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
def acts_as_used_in(*model_symbols)
|
10
|
+
extend ClassMethods
|
11
|
+
include InstanceMethods
|
12
|
+
|
13
|
+
self.uses_of = model_symbols
|
14
|
+
self.label_method = :name
|
15
|
+
|
16
|
+
# Relationships
|
17
|
+
has_many :uses, as: :use_of, class_name: 'Cookbook::Use'
|
18
|
+
associate_uses_of
|
19
|
+
end
|
20
|
+
|
21
|
+
# Extended by acts_as_used_in mixin
|
22
|
+
module ClassMethods
|
23
|
+
attr_accessor :uses_of, :label_method
|
24
|
+
|
25
|
+
def associate_uses_of
|
26
|
+
uses_of.each do |table_sym|
|
27
|
+
model = table_sym.to_s.classify.constantize
|
28
|
+
name = model.model_name.to_s
|
29
|
+
|
30
|
+
has_many "#{model.model_name.param_key}_uses".to_sym, lambda {
|
31
|
+
where(use_in_type: name)
|
32
|
+
}, as: :use_of, class_name: 'Cookbook::Use'
|
33
|
+
has_many table_sym, through: :uses, source: :use_in, source_type: name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Included by has_cookbook mixin
|
39
|
+
module InstanceMethods
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/cookbook.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Cookbook Module
|
4
|
+
module Cookbook
|
5
|
+
require 'active_record/railtie'
|
6
|
+
require 'action_controller/railtie'
|
7
|
+
require 'action_view/railtie'
|
8
|
+
require 'sprockets/railtie'
|
9
|
+
|
10
|
+
require 'cookbook/configuration'
|
11
|
+
require 'cookbook/engine'
|
12
|
+
require 'cookbook/railtie'
|
13
|
+
require 'cookbook/version'
|
14
|
+
|
15
|
+
require 'cookbook/mixins/acts_as_used_in'
|
16
|
+
require 'cookbook/mixins/acts_as_use_of'
|
17
|
+
require 'cookbook/extensions/float'
|
18
|
+
|
19
|
+
require 'haml-rails'
|
20
|
+
require 'sass-rails'
|
21
|
+
require 'simple_form'
|
22
|
+
require 'vanilla_nested'
|
23
|
+
require 'cancancan' if Cookbook.configuration.authorize_with == :cancancan
|
24
|
+
end
|
25
|
+
|
26
|
+
ActiveRecord::Base.extend Cookbook::Mixins::ActsAsUsedIn
|
27
|
+
ActiveRecord::Base.extend Cookbook::Mixins::ActsAsUseOf
|
@@ -0,0 +1,12 @@
|
|
1
|
+
-# frozen_string_literal: true
|
2
|
+
= simple_form_for(@<%= singular_table_name %>) do |f|
|
3
|
+
= f.error_notification
|
4
|
+
= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present?
|
5
|
+
|
6
|
+
.form-inputs
|
7
|
+
<%- attributes.each do |attribute| -%>
|
8
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
9
|
+
<%- end -%>
|
10
|
+
|
11
|
+
.form-actions
|
12
|
+
= f.button :submit
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
5
|
+
|
6
|
+
require_relative 'config/application'
|
7
|
+
|
8
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,65 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
margin: 33px; }
|
5
|
+
|
6
|
+
body, p, ol, ul, td {
|
7
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
8
|
+
font-size: 13px;
|
9
|
+
line-height: 18px; }
|
10
|
+
|
11
|
+
pre {
|
12
|
+
background-color: #eee;
|
13
|
+
padding: 10px;
|
14
|
+
font-size: 11px; }
|
15
|
+
|
16
|
+
a {
|
17
|
+
color: #000; }
|
18
|
+
|
19
|
+
a:visited {
|
20
|
+
color: #666; }
|
21
|
+
|
22
|
+
a:hover {
|
23
|
+
color: #fff;
|
24
|
+
background-color: #000; }
|
25
|
+
|
26
|
+
th {
|
27
|
+
padding-bottom: 5px; }
|
28
|
+
|
29
|
+
td {
|
30
|
+
padding: 0 5px 7px; }
|
31
|
+
|
32
|
+
div.field,
|
33
|
+
div.actions {
|
34
|
+
margin-bottom: 10px; }
|
35
|
+
|
36
|
+
#notice {
|
37
|
+
color: green; }
|
38
|
+
|
39
|
+
.field_with_errors {
|
40
|
+
padding: 2px;
|
41
|
+
background-color: red;
|
42
|
+
display: table; }
|
43
|
+
|
44
|
+
#error_explanation {
|
45
|
+
width: 450px;
|
46
|
+
border: 2px solid red;
|
47
|
+
padding: 7px 7px 0;
|
48
|
+
margin-bottom: 20px;
|
49
|
+
background-color: #f0f0f0; }
|
50
|
+
|
51
|
+
#error_explanation h2 {
|
52
|
+
text-align: left;
|
53
|
+
font-weight: bold;
|
54
|
+
padding: 5px 5px 5px 15px;
|
55
|
+
font-size: 12px;
|
56
|
+
margin: -7px -7px 0;
|
57
|
+
background-color: #c00;
|
58
|
+
color: #fff; }
|
59
|
+
|
60
|
+
#error_explanation ul li {
|
61
|
+
font-size: 12px;
|
62
|
+
list-style: square; }
|
63
|
+
|
64
|
+
label {
|
65
|
+
display: block; }
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Controller for HowTos, like "How to build a dog house"
|
4
|
+
class HowTosController < ApplicationController
|
5
|
+
include Cookbook::Params
|
6
|
+
before_action :set_how_to, only: %i[show edit update destroy]
|
7
|
+
|
8
|
+
# GET /how_tos
|
9
|
+
def index
|
10
|
+
@how_tos = HowTo.all
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /how_tos/1
|
14
|
+
def show; end
|
15
|
+
|
16
|
+
# GET /how_tos/new
|
17
|
+
def new
|
18
|
+
@how_to = HowTo.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /how_tos/1/edit
|
22
|
+
def edit; end
|
23
|
+
|
24
|
+
# POST /how_tos
|
25
|
+
def create
|
26
|
+
@how_to = HowTo.new(how_to_params)
|
27
|
+
|
28
|
+
if @how_to.save
|
29
|
+
redirect_to @how_to, notice: 'How to was successfully created.'
|
30
|
+
else
|
31
|
+
render :new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# PATCH/PUT /how_tos/1
|
36
|
+
def update
|
37
|
+
if @how_to.update(how_to_params)
|
38
|
+
redirect_to @how_to, notice: 'How to was successfully updated.'
|
39
|
+
else
|
40
|
+
render :edit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# DELETE /how_tos/1
|
45
|
+
def destroy
|
46
|
+
@how_to.destroy
|
47
|
+
redirect_to how_tos_url, notice: 'How to was successfully destroyed.'
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_how_to
|
54
|
+
@how_to = HowTo.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Only allow a list of trusted parameters through.
|
58
|
+
def how_to_params
|
59
|
+
params.require(:how_to).permit(:name, :description, :instructions, cookbook_params('HowTo'))
|
60
|
+
end
|
61
|
+
end
|