Rails 3 development environment keeps caching, even without caching on? - ruby-on-rails

i have a rails 3 app in dev mode that won't load any changes i make when its running webrick. i triple checked the settings for my development.rb and made sure i am running in development mode.
config.cache_classes = false
config.action_controller.perform_caching = false
i also checked my tmp directory to make sure the cache folder is empty - i have yet to do any caching on the site and have never turned on caching. im guessing its a loading problem with the files.
also i was running on webrick then installed mongrel and the problem still persists.
im guessing ive run into a config problem, bc i dont see anyone else posting such a prob. anything else im missing?
EDIT: it looks like my view helpers aren't auto loadable - aren't helpers by default supposed to be reloadable in rails 3?

I've had a similar experience, but I don't believe it was with an actual helper class, it was with anything I wrote under the lib/ directory. If you've had to use a require 'some_class' statement, then you should switch it to:
require_dependency 'some_class'
Worked like a charm for me.

I had the same problem and here is the simple solution.
In your config/environments/development.rb set following settings:
config.action_controller.perform_caching = false
config.perform_caching = false
config.cache_store = :null_store

I know this is an old question, but for anyone coming here with a similar issue, make sure you didn't accidentally move production.rb from config/environments/ to config/initializers/ like I did. That will make Rails read in the production.rb file and override your development settings. Whoops.

Had the same issue, it was caused by rails-dev-tweaks gem which is, if you used default configuration from README, disabling stack reload upon AJAX requests.

I'm using Rails 4, and my cache call was in a helper using Rails.cache.fetch.
After googling a bit, I found out this issue (https://github.com/rails/rails/issues/20733), where a PR was merged into rails 5 documentation to make clear that '
Changing the value of config.action_controller.perform_caching will
only have an effect on the caching provided by the Action Controller
component. For instance, it will not impact low-level caching, that we
address below.
', being 'low-level-caching' the Rails.cache.fetch.
It's on the docs now: http://guides.rubyonrails.org/caching_with_rails.html

Related

Rails files not updating unless server restart

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

RoR Can't edit style until config.assets.debug = true

I am using an RoR opensource application, and I want to make some minor changes in it.
Like adding the possibility to use table in CKEDITOR, or embedded an other application to it.
I achieve doing all of this, but I can only see my changes, or style the embedded application if I set config.assets.debug = true in my environments file.
The problem is, when I do that, I have strange behavior in my application... Like when I submit a form, it is submitted twice...
And I absolutely don't know why...( I really don't know much in RoR )
Edit
It seems that the question is not clear... The fact is I don't know what to tell you to get some help...
If I take the exemple of my embedded application:
If I add #import "thredded"; in my application.scss file without setting config.assets.debug = true in my environments file. It is not importing the style...
If I do the same with config.assets.debug = true in my environments file.
It is working... I would like to understand how to make it works without config.assets.debug = true.
Is that a matter of precompile css file or something?
The problem was that I am under production environement, and I was not doin any:
rake assets:precompile RAILS_ENV=production
After that, my changes are applying just fine (still have my problems with double execution of my JS, but that's something else)...

What is Config.Eager_load and how do I fix it?

I've been trying to run a rails db migrate command, and its worked on many apps with the same setup as this one, but for whatever reason I am getting the following error:
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
But here's the thing. All of those are set correctly. I've even tried setting them incorrectly running it, and setting them correct again. I've restarted my computer, my app. Everything. I can't find a good explanation of what config.eagar_load even really is either. What is this thing? Why is it messing up my app? How do I even troubleshoot it?
Answer in part: I was using rails db migrate and should have been using rails db:migrate so that fixed the problem, but I would still like to know what config.eager_load is, and what it does.
I recommend you this great post.

clearing rails cache dynamically

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 ?

Rails Application expecting me to restart my webrick server for any change in my controller

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.

Resources