Skip to content

Instantly share code, notes, and snippets.

@gnepud
Last active April 3, 2016 23:48
Show Gist options
  • Save gnepud/5827411 to your computer and use it in GitHub Desktop.
Save gnepud/5827411 to your computer and use it in GitHub Desktop.
Spree 2.0 + RefineryCMS 2.1.dev
brew update
rvm get stable
rvm requirements
rvm install 2.0.0
rvm use --default 2.0.0
rvm gemset create piron
rvm gemset use piron
gem install rails

rails new refinery_spree
cd refinery_spree
rvm --create --ruby-version use ruby-2.0.0-p195@piron       => .ruby-version and .ruby-gemset

or

rvm --create --versions-conf use ruby-2.0.0-p195@piron      => .versions.conf

gem install spree_cmd

issus spree/spree#2494 edit Gemfile

gem 'jquery-rails', '2.2.1'
spree install

edit Gemfile

gem 'jquery-rails', '~> 2.2.1'

gem 'awesome_nested_set', '2.1.5'

# Refinery CMS
gem 'refinerycms', '~> 2.1.0.dev', :git => 'git://github.com/refinery/refinerycms.git'
gem 'refinerycms-i18n', '~> 2.1.0.dev', :git => 'git://github.com/refinery/refinerycms-i18n.git'

# Spree
gem 'spree', :github => "spree/spree", :branch => "2-0-stable"
gem 'spree_i18n', :github => 'spree/spree_i18n', :branch => "2-0-stable"
gem 'spree_gateway', :github => 'spree/spree_gateway', :branch => "2-0-stable"
bundle install

rails generate refinery:cms --fresh-installation

bundle exec rake railties:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed

add config/initializers/spree.rb

# Configure Spree Preferences
#
# Note: Initializing preferences available within the Admin will overwrite any changes that were made through the user interface when you restart.
#       If you would like users to be able to update a setting with the Admin it should NOT be set here.
#
# In order to initialize a setting do:
# config.setting_name = 'new value'
Spree.config do |config|
  # Example:
  # Uncomment to override the default site name.
  # config.site_name = "Spree Demo Site"
end
Spree.user_class = "Refinery::User"
rails g spree:install --migrate=false --sample=false --seed=false

bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake spree_sample:load

rails g spree:custom_user Refinery::User

rake db:migrate

rails g spree_i18n:install

Update lib/spree/authentication_helpers.rb

module Spree
  module AuthenticationHelpers
    def self.included(receiver)
      receiver.send :helper_method, :spree_login_path
      receiver.send :helper_method, :spree_signup_path
      receiver.send :helper_method, :spree_logout_path
      receiver.send :helper_method, :spree_current_user
      receiver.send :helper_method, :current_user
      # ensure refinery_user? helper method is always available
      receiver.send :helper_method, :refinery_user?
    end

    def spree_current_user
      current_refinery_user
    end

    def spree_login_path
      refinery.new_refinery_user_session_path
    end

    def spree_signup_path
      refinery.new_refinery_user_registration_path
    end

    def spree_logout_path
      refinery.destroy_refinery_user_session_path
    end

    def current_user
      current_refinery_user
    end
  end
end

ApplicationController.send :include, Spree::AuthenticationHelpers

add the following monkey patch to config/initializers/will_paginate.rb

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        alias_method :per, :per_page
        alias_method :num_pages, :total_pages
      end
    end 
  end
end
rails console
Refinery::User.first.spree_roles << Spree::Role.find_or_create_by_name("admin")

Update config/routes.rb to use Refinery for the home page

root :to => "refinery/pages#home"

Helpful links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment