I tried:
after_initialize do #code end
But: (documentation)
Some parts of your application, notably observers and routing, are not yet set up at the point where the after_initialize block is called.
I need routing and logger in my code
Any ideas?
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
One of the things rails server does is that it loads all the dependencies/gems required by your Rails app, or at least sets them up to be auto-loaded later when they are needed. This is sometimes called "booting" or loading the "Rails environment".
How to run an existing Ruby-on-Rails project locally after cloning a repository. The first thing to do is to find the Ruby version used in the Rails project. Then, install the ruby version, bundler gem, dependencies (packages). Finally, set up the database and run the Rails project.
See section 3.1 from http://guides.rubyonrails.org/configuring.html
I believe you would put this code in config/application.rb
config.after_initialize do # .... end # config.after_initialize takes a block which will be run after Rails has finished initializing the application. # That includes the initialization of the framework itself
Also http://guides.rubyonrails.org/initialization.html
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