I have two gems "CoreGem" and "AddonGem". Addon Gem adds extra functionality which will overwrite the core gem.
How do i make sure that if the second gem is added it will overwrite the views and assets of the first.
So far it works when adding to the main app:
config.railties_order = [ :main_app, AddonGem::Engine, :all]
But i'd want to do this from within the AddonGem.
Thanks
99.9% of the time it does not matter, but there are some wierd fringe cases where it can. As has been mentioned, Triggered active gems trigger in the order they are socketed in the item. So for example, if you trigger desecrate and an offering, you want to have the desecrate go off first so that it makes corpses for the offering to consume.
If you want to activate Phase run off a trigger gem, you want it to be the last gem to activate because otherwise the next gem to activate will pull you out of the stealth&speed buff. for gems like "cast when.." or items with effects like this the order of active gems organises what gem is triggered first and what gem comes last. (right?) Right.
In Order and Chaos Online Gems do not stop at level 4. There are many higher level gems. This article only concerns begening gems. Those are the basics of gems. You are sure to learn more about it in game and with experience. Do not skip this part of the game.
A list of gems required for a given (non-gem) project can be listed on a special file called “Gemfile” so they can be automatically installed by Bundler. Both covered later in this guide. What are some examples of gems?
railties_order
is usedrailties_order
is used here:
https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L317
to determine the ordering of initializer
blocks to run,
https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L337
found in other gems.
https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L47
So setting railties_order
inside an initializer
block would be rather pointless, as by the time the initializer
block was called, railties_order
was already set and is in used by the rest of the application.
Apparently a bunch more initializer
blocks are inside the Rails::Application::Bootstrap
.
https://github.com/rails/rails/blob/master/railties/lib/rails/application/bootstrap.rb
Those are prepended before the main application's initializer blocks:
https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L262
So perhaps you can monkey-patch the Bootstrap module with some initializers? I guess that's your call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With