Hello, I have some doubts about how to customize t...
# support
m
Hello, I have some doubts about how to customize the backend with Deface. 1. What is the right way to do it? In the documentation, I can see that I need to create overrides views like this one
add_remove_from_rejected.html.erb.deface
and add my code to it. But if I take inspiration from
solidus_subscription_gem
, for example, I can see something like that
Copy code
Deface::Override.new(
  virtual_path: "spree/admin/products/_form",
  name: "solidus_subscriptions_product_subscribable_checkbox",
  insert_after: "[data-hook='admin_product_form_promotionable']",
  partial: "spree/admin/products/subscribable_checkbox"
)
I'm guessing it does the same thing but I'd like to understand. 2. How do I deploy my changes to production? Both ways seems to work locally but I super confused about how to deploy changes I make in the backend to production. This is probably a stupid question but I cannot wrap my head around it 😅 If I create my overrides views in my main app, it's not working because it cannot find the override partial
Missing partial app/overrides/views/products/_clothing_checkbox
. But any code I add in the backend is of course not tracked by me git repo. Thank you for your help!
r
1. I don’t have any strong opinions on which one to use, as long as it’s well organized, but others may have strong opinions 2. Depends on what platform you are using for production. But deploying changes to the backend should work in the same way to if you are making changes to the frontend (if you are hosting just one app). Could you clarify if you have made production deployments before? What do you mean by “create my overrides views in my main app” as well as “any code I add in the backend is of course not tracked by me git repo”?
m
Of course. So, I'm using Digital Ocean Apps for hosting, and the way it works, so far, is that I can edit my solidus starter frontend (which I referred as my 'main app') locally, then
git add commit push
my code, and deploy it. And this works. But, if I
code bundle open solidus
the backend files and bring changes to them, and do a
git add . git commit -m
I'm getting a
nothing to commit
message. No change is being tracked there. I hope it makes sense.
r
Thanks for the clarification! Making changes to the gem files (
code bundle open solidus
) locally, is good to test stuff, but it won’t affect the production code. Essentially, you’re pushing a commit, which sends all your code, including the Gemfile and Gemfile.lock, which tells production what versions to use for the gems - whatever Solidus version was locked to (
code bundle info solidus
), will be what production uses. If you want to override code inside Solidus, you have a few options • For models or class files, this guide should help • But for views: ◦ for frontend, as you used the frontend_starter, you can change the views you have locally in your codebase; and ◦ for the backend, you can deface it like you mentioned (looks like you have already looked at this guide) (you can also override the whole file but may require more maintenance in the future). The new code you’ll add needs to be in your code, so you can commit it.
👀 1
Btw, I also too change local gems for testing as you are doing. If you ever want to reset solidus back to what production will use/what it should be, you can do
code bundle pristine solidus
Let me know if this helps and if you have any more questions (no question is stupid 🙂). Any feedback on the guides and what could be improved, is appreciated as well 🤗
💙 1
🙏 1
m
Alright, thanks a lot Ryan 🙂 It already makes more sense. I will look into that direction and let you know if I have any other question!
👍 1
k
@Marie Lamoureux I think you can add backend code to your app as well. The backed is still part of your application, it’s just in a different folder. Be sure you are putting the files into
app/views/spree/admin/something
.
m
@kennyadsl is there a command to add the backend files to my app, or do I need to add the files I need manually ?
k
Unfortunately not at the moment.