Whenever I make changes in the controller or models I need to re-start the server. Please, kindly clarify me. Rails version 5.2.2
Check yourconfig/environments/development.rb file and see if you can find these lines:
set config.cache_classes = false and
config.reload_classes_only_on_change = false
You can refer to these answers:
Rails Server needs restart every time I make changes? why?
Vagrant shared folder with rails server
Related
I am working on a Ruby on Rails project, and each time I want my changes to take effect (views, controllers, anything really) I am forced to close the server and restart it. I tried to find a solution to this but Googling it didn't help me at all. Does anyone know how to fix this issue?
Go to config/environments/development.rb and add these two configs or change them to false
config.cache_classes = false
config.eager_load = false
I am working on rails application , in which i am using ruby 1.9.2 and rails 3.0.8. My application is running quite fine in development environment, which includes creating tables from the application and accessing them.
But when i start my application in production environment in which caching is enabled, every thing is working fine , i am not able to access the table which i am creating using my application. I am able to access these tables after restarting the server, which is a pain.
I am searching for a way where i can clear the cache whenever new table get created, can you please help me to clear the cache dynamically.
Thanks
Naveen Kumar Madipally
The one workaround would be to do this in your environments/production.rb (which is not at all recommended on production)
config.cache_classes = false
this will decrease your performance in production but what you can do is fo to production.rb file and check the blow lines
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
i guess it will solve your problem
There are abstractions for that in ActionDispatch::Reloader : it's what's used in development environment to reload classes.
So basically, you would need to run :
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
I'm not sure it would be such a good idea, though, as you can't expect which code (yours or from gems) does things that are supposed to happen only once.
Couldn't you use STI rather than dynamicly creating tables ?
I'm trying to speed up my web fronted by caching classes in development,
My::Application.configure do
config.cache_classes = true
end
but I would like to manually reload classes using guard if a file in my model or lib changes.
So the question is this: without restarting my local server, how can i manually trigger a class cache refresh?
Update
You can use reload!
don't know why i didn't think of that sooner
Even I don't answer your raw question, this link should answer your goal as a whole.
In a nutshell:
Reload Rails code in development mode only when change is detected
I'm developing a Ruby on Rails project related to semantic technology, and I'm making something basic that allow the uploading of files and searching in those files.
So far it's all working out ok, but I have noticed that when I make changes to my code files or haml files, I don't see those changes on the webserver. Only after either rebooting the server or mashing the F5 button like crazy, the changes come through. And even that is not guaranteed.
The server is running on a local, virtual, ubuntu system. This is an Apache2 webserver configured with Passenger. The website is visibile, it's just not always the latest changes.
Anyone have an idea what might be causing this, or how I can fix this?
In your config/environments/environment_name.rb file it's likely that you have these lines:
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
Which you can switch to have the behavior you want.
If you don't want to change these then you can just touch tmp/restart, which will push the changes through (it's quicker and more graceful then restarting the web server)
To change the environment passenger runs in add the following line to your vhost:
RailsEnv development
I am working on an existing Rails 2.3.x application, So I was working on it and it was a messy code with great difficulty I was able to run the application. But now for every small change in one of my controller it is expecting me to restart my serer otherwise the changes are not reflecting back, Let's take an example scenario here, Let's just say in one of the before_filter method I just added a puts statement on top of the method and it was not printing in the log, after I restart the server it is printing, Can some one please let me know if I am missing something here.
What environment are you using?
The default environment is 'development', where the code is reloaded on each request. However, this behaviour can be overwritten in the config file.
To be sure that the code is reloaded, add this into your config/development.rb file:
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
If you are using config.threadsafe! It needs to be present before config.cache_classes=false as threadsafe makes cache_classes true again, following link would make it more clear. here
Maybe you have don't flush. The log system in Rails use a BufferedLogger. So need a flush to be print. Try a default logger.