Lucien
Lucien

Reputation: 21

Rails route with Spree

I'm trying to add routes but the link in my view does not work, I have the message

undefined local variable or method `styles_path' for #<#<Class:0x007fea4e48a3d8>:0x007fea56135c98>

my routes :

Rails.application.routes.draw do

  get '/styles/:id' => 'spree/spreepages#show_taxonomy', as: 'show_taxonomy'
  get '/styles'     => 'spree/spreepages#choose_style', as: 'styles'

  mount Spree::Core::Engine, at: '/'
          root to: 'pages#home'
end

and my view

<div class="col-sm-2 choose-style-steps">
    <%= link_to "", styles_path do %><div class="steps step-one">1</div><% end %>
    <%= link_to('#') do %><div class="steps step-two">2</div><% end %>
    <%= link_to('#') do %><div class="steps step-three">3</div><% end %>
  </div>
</div>

I try with spree.styles_path but it does not work

Output of rails routes

       Prefix Verb URI Pattern           Controller#Action
        spree      /                     Spree::Core::Engine
         root GET  /                     pages#home
show_taxonomy GET  /styles/:id(.:format) spreepages#show_taxonomy
       styles GET  /styles(.:format)     spreepages#choose_style

Routes for Spree::Core::Engine:
                                          locales GET                       /locales(.:format)                                                            spree/locale#index
                                       set_locale POST                      /locale/set(.:format)                                                         spree/locale#set {:format=>:json}
                     skrill_cancel_order_checkout GET                       /orders/:order_id/checkout/skrill_cancel(.:format)                            spree/checkout#skrill_cancel
                     skrill_return_order_checkout GET                       /orders/:order_id/checkout/skrill_return(.:format)                            spree/checkout#skrill_return
                               new_order_checkout GET                       /orders/:order_id/checkout/new(.:format)                                      spree/checkout#new

And some other Spree Route

Thank's for your help

Upvotes: 2

Views: 874

Answers (2)

Ashish Chougule
Ashish Chougule

Reputation: 46

I know it is too late but for future use.

In main_app you will get all the details about your project. So you can use it as per below,

link_to main_app.styles_url

or

link_to main_app.styles_path

Upvotes: 2

Lucien
Lucien

Reputation: 21

I found it, just put the url in place of path like

link_to styles_url

Upvotes: 0

Related Questions