is the console in rails (~ rails c
) dynamic? For example; if I open the console and then make changes to a model will it pick these changes up or do I have to exit out of the console and run rails c
again for it to pick up the changes in the model?
Rails console is an irb session that is built into the rails environment and is accessed by typing rails c into the terminal. It can be used to test association methods, validations and check error messages when building a rails app.
The Rails console. provides a way to interact with your GitLab instance from the command line. The Rails console interacts directly with GitLab. In many cases, there are no handrails to prevent you from permanently modifying, corrupting or destroying production data.
You will need to call the reload!
method in the console to reload the changes. This method's magic is automatically called by rails server
in development mode.
As a comment's pointed out beneath and another answer here, if you change things to do with the environment of the application, such as adding new gems to the Gemfile
, making changes to anything in config
or adding a new plugin then you'll need to restart the console. Any changes to app
will be reloadable with reload!
If you were using this particular way to test that a method was working, I wouldn't. Tests (as in, the Test::Unit or RSpec) variants are much nicer because you have a reproducible way of running them again and again. rails console
is great for one-off testing, but if you want to write a maintainable application then write tests.
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