You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pls help.
After installing ratyrate and i've done like in Instruction at GItHub
I got this undefined method `overall_avg' for #Recipe::ActiveRecord_Relation:0x007f5154d4ea20
my user.rb
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
ratyrate_rater
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :recipe
end
- @recipe.each_slice(3) do |recipes|
.row
-recipes.each do |recipe|
.col-md-4
.recipe
.image_wrapper
= link_to recipe do
=image_tag recipe.image.url(:medium)
%h2= link_to recipe.title,recipe
.row
.small-2.large-2.columns
= imdb_style_rating_for @recipe, current_user
%br/
.small-2.large-4.columns
- if current_user
Recipe Ratings: #{rating_for @recipe, "recipe_rating"}
my ricipes_controller
class RecipesController < ApplicationController
before_action :find_recipe, only: [:show,:edit, :update, :destroy]
before_action :authenticate_user!, exept: [:index, :show]
def index
@recipe = Recipe.all.order("created_at DESC")
end
def show
end
def new
@recipe = current_user.recipe.build
end
def create
@recipe = current_user.recipe.build(recipe_params)
if @recipe.save
redirect_to @recipe, notice: "Successfully created new recipe"
else
render 'new'
end
end
def edit
end
def update
if @recipe.update(recipe_params)
redirect_to @recipe
else
render 'edit'
end
end
def destroy
@recipe.destroy
redirect_to root_path, notice: "Successfully deleted recipe"
end
private
def recipe_params
params.require(:recipe).permit(:title, :description, :image, ingredients_attributes: [:id, :name, :_destroy], directions_attributes: [:id, :step, :_destroy])
end
def find_recipe
@recipe = Recipe.find(params[:id])
end
end
The text was updated successfully, but these errors were encountered:
Pls help.
After installing ratyrate and i've done like in Instruction at GItHub
I got this
undefined method `overall_avg' for #Recipe::ActiveRecord_Relation:0x007f5154d4ea20
my user.rb
my index.html.haml
my ricipes_controller
The text was updated successfully, but these errors were encountered: