Adding Refinery CMS into a main Spree application as a Rails engine - idea that all static pages managed by Refinery, for example to build all our footer pages
http://refinerycms.com/guides/with-an-existing-rails-app
Some useful info here but probably superseded by latest developments :
http://rohanmitchell.com/2012/04/spree-refinery-together-spreefinery/
Add refinery to bundle, gem install etc, then
rails generate refinery:cms --fresh-installation
Makes a bit of a mess of the migrations, all the spree ones reappeared, so needed to tidy up a bit before running
bundle exec db:migrate
Then check db/seeds.rb and make sure only the new refinery stuff will run (I commented out some spree load_seed calls)
bundle exec rake db:seed
Edit routes.rb to move the Refinery mount below the Spree engine
Check the initializers in config/initializers/refinery/ to customize your experience.
Setup User Authentication - this seemed to work well...
https://github.com/adrianmacneil/spree-refinery-authentication#readme
Sets the Spree.user_class = "Refinery::User" but to be sure I set it also in initializers/spree to ... Spree.user_class = "Refinery::User"
Issue when actually visting a refinery Page : undefined method `refinery_user?' when use with ActiveAdmin
Solution via google seems to be to add following to helper_method :refinery_user?
So seemed like a good idea to bring in all the helpers from both engines...
class ApplicationController < ActionController::Base
protect_from_forgery
# share helpers across both Spree + Refinery controllers
# helper_method :refinery_user?
helper Refinery::Core::Engine.helpers
layout 'spree/layouts/spree_application'
include Spree::Core::ControllerHelpers
include Spree::BaseHelper
helper 'spree/base'
helper 'spree/products'
end
This resolved most issues with using refinery within the spree_application layout apart from something odd with routes
Trying to go to a refinery page like http://localhost:3000/pages/customers, causes routing error in spree-core app/views/spree/shared/_search.html.erb ... being pulled in by shared spree layout
undefined method `products_path' for #<#<Class:0xd3ab4b8>:0xd326ed4>
Extracted source (around line #2):
2: <%= form_tag products_path, :method => :get do %>
This is a bog standard Spree route but it's not available to the refinery controllers. I presumed routes were global in scope, wasn't even aware that routes were controller specific.
TO FIND OUT are they - Yes, routes are indeed part of the namespace, so fix is to use
spree:products_path
Alterntative fix is to switch back to fully specified routes (e.g in spree/_search.html.erb with
<%= form_tag(:url => {:controller => 'spree/products', :action => :index}, :method => :get) do %>
How to include a refinery page as a partial ? i.e I want to create and manage my footer in Refinery but for that footer page to be included in the main layout and every page, so effectively rendered as a partial