Hi Hartmut,
My suggestion would be to add your code in the initialisers folder,
something like config/initializers/console.rb and this will run after Rails
has initialised its environment.
However this will run every time you run a rails or rake command, so to
avoid that you could add something like this to your console initialiser:
if Rails.const_defined?("Console")
# your code here
end
And this will run only if you are on a Rails console.
When I tried the code myself I had some problems with the binaries
generated by spring, so you might need to update them if it doesn't work.
rake rails:update:bin or rails app:update:bin if you're on Rails 5.
Hope it works.
Kind regards,
/ Marco
On Mon, Feb 6, 2017 at 10:41 AM hartmut bischoff <[email protected]>
wrote:
Hi everbody,
I am working on a Rails Project using OrientDB as Database (
https://github.com/topofocus/active-orient )
This gem initializes any available database-class and assigns it to
model-classes.
For me its convenient to recognize, which database-classes are found, when
starting the console.
Thus I patched the source in railties/rails/lib/commands/console.rb
Obviously, I am not happy with this dirty approach.
How is this done properly?
in detail:
I want to execute some ruby-code after any initialization of the core and
before the first command can be entered.
This code prints out some status information.
Any help is appreciated
greetings from Stuttgart
hartmut
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/0ea5a569-6d70-490e-b1f1-b2bca5150065%40googlegroups.com
<https://groups.google.com/d/msgid/rubyonrails-talk/0ea5a569-6d70-490e-b1f1-b2bca5150065%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/CACMkcE54uJEBv-aceUNum4zfEOpT%3Dt4g%3DC73nABXAEa%2BXSEutQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.