I'm creating a view that list all vendors using Spree Multi Vendor extension for Spree Commerce.
My index.html.erb
template :
<% @vendors.each do |vendor| %>
<h2>
<%= vendor.name %>
</h2>
<% end %>
My stores_controller.rb
controller :
module Spree
class StoresController < Spree::StoreController
def index
@vendors = Spree::Vendor
end
end
end
The error that I'm getting :
NoMethodError in Spree::Stores#index
Showing /myapp/app/views/spree/stores/index.html.erb where line #36 raised:
undefined method `each' for # < Class:0x00007fe3f5570a40 >
Line #36 : <% @vendors.each do |vendor| %>
How can I correctly instantiate Vendor Model
inside my controller so I can use it's methods and access it's attributes in the views of my store ?