Skip to content

Commit

Permalink
Merge pull request #50 from jatwell93/setupHookToCurrentUser
Browse files Browse the repository at this point in the history
smoothed out views for recipe to match controller revamp
  • Loading branch information
jatwell93 authored Jun 18, 2017
2 parents b7879a7 + e8f80e0 commit 302e62d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ DEPENDENCIES
simple_form
social-share-button
sqlite3
trollop
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion app/models/direction.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions app/views/recipes/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@
<% end %>
<br>
<br>
<strong>Feeds: </strong>
<%= 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 %>
<strong>Servings Made: </strong>
<%= f.text_field :servings_made %>
<br>
<br>
<strong>Preptime: </strong>
<%= 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 %>
<br>
<br>
<strong>Calories: </strong>

<%= f.text_field :calories %>
<br>
<br>

Expand Down
2 changes: 1 addition & 1 deletion app/views/recipes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<p>Ingredients: <%= render recipe.ingredients %></p>
<% end %>

<p>Feeds: <%= recipe.feeds %></p>
<p>Feeds: <%= recipe.servings_made %></p>

<p>Preptime: <%= recipe.prep_times %></p>

Expand Down
3 changes: 2 additions & 1 deletion app/views/recipes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
<p>Styles: <%= render @recipe.styles %></p>
<% end %>

<p>Feeds: <%= @recipe.feeds %></p>
<p>Feeds: <%= @recipe.servings_made %></p>
<p>Preptime: <%= @recipe.prep_times %></p>
<p>Calories: <%= @recipe.calories %></p>

<p><strong>Notes:</strong></p><%= simple_format(@recipe.description) %>
<div class="pull-right">
Expand Down

0 comments on commit 302e62d

Please sign in to comment.