Hey folks, I’m working on a Rails app with multiple engines and I’m trying to set up Spree backend in one of them. Here’s what I’ve got:
- A core engine with Spree and auth_spree models plus some custom ones
- An API engine (different from spree_api)
- A backend engine where I want to use Spree backend with my core models
I managed to get the admin page working by tweaking the backend engine routes:
MyBackend::Engine.routes.draw do
root to: "admin/orders#index"
mount Spree::Core::Engine, at: '/'
end
But now I’m running into issues with assets and routes in spree.js.coffee.erb. Has anyone dealt with this before? Is there a way to use Spree backend without its models? How would auth work in this setup?
Any tips or tricks would be super helpful. Thanks!
hey there! i’ve dealt with similar setups before. one trick is to use spree’s deface gem to customize views without touching core files. for auth, you might wanna look into devise + cancancan combo. also, double-check your asset pipeline config - sometimes its tricky with engines. good luck with ur project!
hey echo_vibrant! have u considered using spree’s mountable engine approach? it might help with ur asset issues. for auth, maybe try devise_token_auth? it plays nice with separate engines. btw, whats ur main reason for splitting things up? curious about ur architecture choices!
I’ve encountered similar challenges when working with Spree in a multi-engine setup. One approach that worked for me was to create a wrapper engine that includes both Spree and your custom functionality. This allows you to maintain separation while leveraging Spree’s features.
For asset issues, ensure you’re properly requiring and precompiling assets across engines. You might need to adjust your application.rb and engine.rb files to include the necessary paths.
Regarding authentication, consider using Spree’s existing auth system and extending it for your needs. This can be done by overriding controllers and adding custom logic where necessary.
Remember to carefully manage dependencies between your engines to avoid circular references. It’s a complex setup, but with proper architecture, it can be quite powerful and flexible.