Reputation: 3841
Firstly here is my file structure
module ApplicationHelper
def show_stars(review)
image_tag review.rating
end
end
class CustomersController < ApplicationController
before_action :require_admin
# reviews
def reviews
@reviews = Review.all
end
end
%table.table.table-striped
%thead
%tr
%th{ :style => "width:8%" } Ratings
%tbody
- @reviews.each do |review|
%tr
%td{ :style => "text-align:center" }= review.rating.show_stars
I have rating
setup as a integer in my schema and what I am trying to do is convert the integer into a star image via the application helper. However when i try using my method i end up getting
undefined method `show_stars' for 4:Fixnum // 4 is my rating value
What am I missing here? I'm just starting out on ruby so any advice is appreciated.
Upvotes: 0
Views: 508
Reputation: 10825
Your method accepts rating (signature show_stars(review)
), so use it properly: change review.rating.show_stars
to show_stars(review)
Upvotes: 2