ruby on rails - RoR - undefined method `hello' for Karlsgem::KarlsGeming:Class -
undefined method `hello' karlsgem::karlsgeming:class
please help, want display string in view cant seem wrap head around this?? in wrong file?
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 |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 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
you defined hello instance method. in order karlsgem::karlsgeming.hello
have define class method:
require "karlsgem/version" module karlsgem class karlsgeming def self.hello puts "hello world" end end end
Comments
Post a Comment