I'm trying to create a route that link to the store page of each Vendor using Spree Commerce. The page should list the details (name, about us, etc), and the products of the given vendor.
https://example.com/stores/vendor-one
My routes.rb configuration :
Spree::Core::Engine.routes.draw do
resources :stores
end
My stores_controller controller :
module Spree
class StoresController < Spree::StoreController
require 'vendor'
def show
@vendor = current_spree_vendor
end
end
end
My show.html.erb template :
<h2><%= @vendor.name %></h2>
<p><%= @vendor.about_us %></p>
The error that I'm getting :
NoMethodError in Spree::Stores#single
Showing /myapp/app/views/spree/stores/show.html.erb where line #2 raised:
undefined method `name' for nil:NilClass
Line # 2 :
<h2><%= @vendor.name %></h2>
How can I load the given Vendor by getting its name from the url ? I'm new to Rails so any help will be highly appreciated !