Skip to content

Commit

Permalink
prep_times & feeds as variables recipe table, rather than assocations…
Browse files Browse the repository at this point in the history
…...did not strip view checkboxes, might need change
  • Loading branch information
Mirv committed Jun 16, 2017
1 parent 238a6fc commit 66d10f2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
21 changes: 12 additions & 9 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,22 @@ def recipe_params
:name,
:summary,
:description,
:prep_times,
:prep_times, # fails assert always valid
:servings_made,
:feeds,
:user_id,

# :picture,
# :chef_id,
# style_ids: [],
# ingredients_attributes: [:id, :name, :_destroy],
# directions_attributes: [:id, :name, :step, :_destroy],
# feed_ids: [],
# calorie_ids: [],
# preptime_ids: []

:picture,
style_ids: [],
ingredients_attributes: [:id, :name, :_destroy],
directions_attributes: [:id, :name, :step, :_destroy],

# calorie_ids: [], # Need to replace

# preptime_ids: [] # Don't use anymore
# feed_ids: [], # Don't use anymore
# :chef_id, # Don't use anymore
)
end

Expand Down
17 changes: 12 additions & 5 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ class Recipe < ActiveRecord::Base
has_many :ingredients
has_many :directions
has_many :reviews
has_many :recipe_calories
has_many :comments, as: :commentable
has_many :calories, through: :recipe_calories
has_many :recipe_preptimes
has_many :preptimes, through: :recipe_preptimes

has_many :recipe_feeds
# Going to a integer & no relationship
### Going to a integer & no relationship ####
### Going to a integer & no relationship ####

# has_many :feeds, through: :recipe_feeds
# has_many :recipe_preptimes
# has_many :preptimes, through: :recipe_preptimes
has_many :recipe_calories
has_many :calories, through: :recipe_calories

### Going to a integer & no relationship ####
### Going to a integer & no relationship ####

# searchkick
accepts_nested_attributes_for :ingredients,
reject_if: proc { |attributes| attributes['name'].blank? },
Expand Down
7 changes: 3 additions & 4 deletions app/views/recipes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
<p>Ingredients: <%= render recipe.ingredients %></p>
<% end %>

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

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

<% if recipe.preptimes.any? %>
<p>Preptime: <%= render recipe.preptimes %></p>
<% end %>

<p>
<span class='quiet'><small>Created: <%= time_ago_in_words(recipe.created_at)%> ago</small></span><br>
Expand Down
4 changes: 1 addition & 3 deletions app/views/recipes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
<% end %>

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

<% if @recipe.preptimes.any? %>
<p>Preptime: <%= render @recipe.preptimes %></p>
<% end %>
<p><strong>Notes:</strong></p><%= simple_format(@recipe.description) %>
<div class="pull-right">
<%= link_to like_recipe_path(@recipe, like: true), :method => :post do %>
Expand Down

0 comments on commit 66d10f2

Please sign in to comment.