Change spree application layout file to load
Asked Answered
F

2

5

Is it possible to use my own application layout file in my main rails app instead of spree's? I have my main app already setup with devise and then added spree. Spree frontend uses

frontend/app/views/spree/layouts/spree_application.html.erb

in its own gem as its layout and I read how to override that file with my own in app/overrides or Deface, but I don't want to duplicate the content that is already in my app/views/layouts/application.html.erb.

I'm looking to use my own file instead or overriding spree's.

Frankfrankalmoign answered 17/2, 2014 at 22:55 Comment(0)
A
10

You have 2 options:

  1. Create a app/view/spree/layouts/spree_application.html.erb in your rails app and rails will pick your file
  2. Set your own layout with Spree::Config[:layout] in an initializer (ex: Spree::Config[:layout]='application')
Algometer answered 17/2, 2014 at 23:6 Comment(5)
Spree::Config[:layout]='application' This worked exactly as I needed. Is this documented any where if I need to make other changes?Frankfrankalmoign
For some reasons, changing Spree::Config[:layout] did not work for me. But overriding spree_application.html.erb did. Thanks!Defection
Second solution with Spree::Config[:layout]also works for me but I had to use 'layouts/application', not just 'application'.Defection
Spree::Config[:layout]='application' worked for me but now I cannot switch back to spree_application layout. Removing that line does not help. If I want to switch to any layout then I have to mention it.Kuhn
In what file did you add it?Lacrimatory
K
2

Spree::Config[:layout]='application' worked for me. But when I tried to switch to the spree default layout by removing this line, it did not work. After spending almost an hour I was able to switch back to default Spree::Config[:layout]='spree/layouts/spree_application' Adding this answer just in case someone else gets stuck with similiar error.

Kuhn answered 3/11, 2015 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.