install spree backend in a separate extension or engine

415 views Asked by At

I am running into a complicated case using spree. I have a components-based rails app with 3 spree engines or extensions:

  1. my_core: contains spree and auth_spree models + my own extra models

  2. my_api: contains the api for my app (totally different than spree_api)

  3. my_backend: here I want to install spree_backend but use my_core models of corse.

Is there any way to install spree_backend without models? and how would the authentication flow works inside?

In my routes I have:

# config/routes.rb
Rails.application.routes.draw do
  constraints :subdomain => 'api' do
    mount MyAPI::Engine, at: "/"
  end
  constraints :subdomain => 'admin' do
    mount MyBackend::Engine, at: "/"
  end
end

# components/my_backend/config/routes.rb
MyBackend::Engine.routes.draw do
  root to: "spree/admin/orders#index"
  mount Spree::Core::Engine, :at => '/'
end

Updates 19-06-2015

I finally could lunch the admin page by modifying the engine routes:

# components/my_backend/config/routes.rb
MyBackend::Engine.routes.draw do
  root to: "admin/orders#index"
  mount Spree::Core::Engine, :at => '/'
end

Moreover, I had to fix many issues with assets. But still facing one issue with routes in spree.js.coffee.erb file

enter image description here

Is there something I am doing wrong? Any suggestions will be very appreciated!!!

1

There are 1 answers

0
Moh On

I solved this issue if someone need it, by creating a new file spree.js.coffee.erb in my engine vendor directory and overriding the method @mountedAt of that class to:

@mountedAt: ->
    "<%= MyBackend::Engine.routes.url_helpers.spree_path %>"