diff --git a/Gemfile.lock b/Gemfile.lock index 5b4917a..7ecfaeb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -464,7 +464,6 @@ DEPENDENCIES simple_form social-share-button sqlite3 - trollop turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) diff --git a/app/controllers/recipes_controller.rb b/app/controllers/recipes_controller.rb index 0bea0f8..c7c45b2 100644 --- a/app/controllers/recipes_controller.rb +++ b/app/controllers/recipes_controller.rb @@ -33,6 +33,7 @@ def create @recipe = Recipe.new(recipe_params) # @recipe.user_id = current_user + @recipe[:user_id] = current_user.id if @recipe.save flash[:success] = "Your recipe was created successfully!" redirect_to recipes_path @@ -95,10 +96,9 @@ def set_user end def recipe_params - params.require(:recipe).permit( - :name, :summary, :description, :prep_times, - :servings_made, :feeds, :user_id, :calories, - :picture, + params.require(:recipe).permit( + :name, :summary, :description, :prep_times, :servings_made, + :user_id, :calories, :picture, style_ids: [], ingredients_attributes: [:id, :name, :_destroy], directions_attributes: [:id, :name, :step, :_destroy]) diff --git a/app/models/direction.rb b/app/models/direction.rb index 6587e18..3660784 100644 --- a/app/models/direction.rb +++ b/app/models/direction.rb @@ -1,5 +1,5 @@ class Direction < ActiveRecord::Base belongs_to :recipe - validates :name, presence: true, length: { minimum: 5, maximum: 100} + validates :step, presence: true, length: { minimum: 5, maximum: 100} end diff --git a/app/models/recipe.rb b/app/models/recipe.rb index 15672d4..fdea6d3 100644 --- a/app/models/recipe.rb +++ b/app/models/recipe.rb @@ -24,7 +24,7 @@ class Recipe < ActiveRecord::Base validates :description, presence: true, length: { minimum: 5, maximum: 1000} validates :servings_made, presence: true validates :prep_times, presence: true - validates :feeds, presence: true + # validates :feeds, presence: true validates :calories, presence: true # mount_uploader :picture, PictureUploader diff --git a/app/views/recipes/_form.html.erb b/app/views/recipes/_form.html.erb index 3e90c8f..4f2d013 100644 --- a/app/views/recipes/_form.html.erb +++ b/app/views/recipes/_form.html.erb @@ -46,20 +46,16 @@ <% end %>

- Feeds: - <%= f.collection_check_boxes :feed_ids, Feed.all, :id, :people do |cb| %> - <% cb.label(class: "checkbox-inline input_checkbox") {cb.check_box(class: "checkbox") + cb.text} %> - <% end %> + Servings Made: + <%= f.text_field :servings_made %>

Preptime: - <%= f.collection_check_boxes :preptime_ids, Preptime.all, :id, :time do |cb| %> - <% cb.label(class: "checkbox-inline input_checkbox") {cb.check_box(class: "checkbox") + cb.text} %> - <% end %> + <%= f.text_field :prep_times %>

Calories: - + <%= f.text_field :calories %>

diff --git a/app/views/recipes/index.html.erb b/app/views/recipes/index.html.erb index 85fcc84..d4e1731 100644 --- a/app/views/recipes/index.html.erb +++ b/app/views/recipes/index.html.erb @@ -33,7 +33,7 @@

Ingredients: <%= render recipe.ingredients %>

<% end %> -

Feeds: <%= recipe.feeds %>

+

Feeds: <%= recipe.servings_made %>

Preptime: <%= recipe.prep_times %>

diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index df83224..a8a3cf9 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -34,8 +34,9 @@

Styles: <%= render @recipe.styles %>

<% end %> -

Feeds: <%= @recipe.feeds %>

+

Feeds: <%= @recipe.servings_made %>

Preptime: <%= @recipe.prep_times %>

+

Calories: <%= @recipe.calories %>

Notes:

<%= simple_format(@recipe.description) %>