Karlsgem::KarlsGeming:Class 的未定义方法“你好”
请帮忙,我只是希望它在视图中显示字符串,似乎无法解决这个问题?我在错误的文件中吗?
karlsgem.rb
require "karlsgem/version"
module Karlsgem
class KarlsGeming
def hello
puts "Hello World"
end
end
end
index.html.erb
<% if notice %>
<p id="notice" ><%= notice %></p>
<% end %>
<%= @kgem %>
<h1>Your Drinks Catalog</h1>
<% @products.each do |product| %>
<div class="entry" >
<%= image_tag(product.image_url) %>
<h3><%= product.title %></h3>
<%=sanitize product.description %>
<div class="price_line" >
<span class="price" >€<%= product.price %></span>
<%= button_to 'Add to Cart' , line_items_path(:product_id => product) %>
</div>
</div>
<% end %>
store_controller.rb
require 'karlsgem'
class StoreController < ApplicationController
def index
@products = Product.all
@cart = current_cart
@kgem = Karlsgem::KarlsGeming.hello
end
end