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)...
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 have this bizarre behavior that I cannot even debug. Usually development is supposed to run a little slower than production. Not only is it now running extremely fast, but it does not recognize my javascript code (it does recognize javascript outside of the assets/javascripts directory), unless I modify the javascript code and refresh page or simply just refresh the page (and then it will only work for that one request).
The reason why I am stumped is because I have the following in /config/environments/development.rb:
config.assets.debug = true
Furthermore, my development.rb is set to the factory defaults.
Any idea how I can further troubleshoot this issue?
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 deploying my Rails app on Heroku (Cedar), and there were 3 options about precompiling my assets I could choose from, and I chose the option where Heroku precompiles my assets on deployment.
When I pushed, I got an error that it cannot access my database (during precompiling). So, how to make Rails not connect to the database during precompiling? I don't know why it's set in the first place, because I can't imagine a scenario where precompiling would need access to the database.
I saw somewhere a solution to disable initializing the application on precompiling, which is achieved by adding the following into the application.rb (setting it in the environments/production.rb doesn't work):
config.assets.initialize_on_precompile = false
I tried adding this line, and it works, but I don't know if it is a good solution. Wouldn't this make some plugins you would potentially use for the assets not load during precompiling, thus affecting the end result?
What you're doing is the correct way. If you don't use models / anything else which is actually accessing the database in your assets then you have no need for it. The only time you'd need to have your app initialized is if you were doing things like this: (Completely contrived example, but you can see what I'm getting at)
/* In some css file */
.some_class{
#{User.find(1).avatar_url}
}
If you enable Heroku Labs (http://devcenter.heroku.com/articles/labs-user-env-compile) you can have access to your Db at deployment time which works great.
Do you use Devise? That's usually a culprit for DB access on precompiling assets incidentally.
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