I'm developing a Rails app using the rails s WEBrick server. For some reason, even though I'm in development mode, one of my controller classes looks like it's still being cached since the controller's class variable values are persisting between page requests.
Is this an expected behavior, considering that in my config/environments/development.rb file, I have the following settings?
config.cache_classes = false
config.action_controller.perform_caching = false
Thanks!
UPDATE: Really, I'm mostly looking to understand why the controller's class variables continue to store their values between page requests when I'd expect those values to be cleared every time I navigate to a new page.
By default, Rails reloads classes only if they change. This can be changed by setting
config.reload_classes_only_on_change = false
This should reload the classes on every request and reinitialize the class variables.
Related
I make debug on a website running on cakephp 2 (yes it's old i know)
I have strange errors i cannot resolve.
in log i have:
-Error: [MissingControllerException] Controller class Wp-login.phpController could not be found
-Error: [MissingControllerException] Controller ColonisersController could not be found.
-Error: [MissingActionException] Action ImgController::ui-bg_diagonals-thick_90_eeeeee_40x40.png() could not be found.
-Error: [MissingActionException] Action ImgController::moustique-tigre-default.png() could not be found.
...
I search over all the source code for Colonisers but it is not write even once (also i think ColonisersController is a renammed controller because it is misspelled).
I search over the web for the Wp-login.php and it is a wordpress page, so no link to cakephp at all, also not write anywhere in the source code.
Same story for the missings pngs files. not in the source code.
I try to clear the cache folder on server but problems remains.
I have ghost source code? file are somewhere in another cache ?
any idea are welcomed.
By default all request that do not map to an actual file are being passed over to CakePHP, where the app will try to match the request to a route, and if one is found, finally try to match it to a controller and an action.
You seem to have some rather unspecific routes defined that eat pretty much anything as a possible controller name, hence things are being passed further for searching for a matching a controller and an action, which is where the request flow will end, as no matching controller or action can be found - consequently a MissingControllerException or MissingActionException is being triggered, an error is being logged (by default all exceptions are being logged), and in production mode (debug = 0) the app will respond with a 404 error.
So, no ghosts, no cached files, that's just how things work.
I'm fairly new to Express and am having an issue. I have node_env set to production and app.get('view cache') is returning true. However, it doesn't appear to be caching my jade baseed views. I can see get with a 304, but my view render is still being called every time.
Am I misunderstanding what this setting is for?
Edit: I guess this setting is really just to make views templates perform better in production. Am I to assume then the express does not support caching of dynamically generated view content?
I noticed adding res.header('Cache-Control', 'max-age=60, must-revalidate');
Is there a cleaner way to do this? thanks
When the 'view cache' setting is true, it caches the compiled javascript of the jade templates.
It doesn't however, cache the jade into a fully static document.
If you wished to do this, you could render the jade once in your app and store the result as a file or in memory. Then you just serve this rendered jade to your client.
I'm finding it difficult to understand how ActiveAdmin(http://activeadmin.info/) works with existing controllers
I have the following controllers
app/controllers/projects_controller.rb
and I was successfully able to implement ActiveAdmin UI over my views in the above controller. But my question is I have added the following before_filter in my controller
class StaticContentsController < ApplicationController
before_filter :list_content_types
def index
#static_contents = StaticContent.all
end
end
But this filter seems to be not executing, in fact I changed the code inside the index method to
#static_contents = abc StaticContent.all
As it should give and error because of 'abc' section, but surprisingly my app works with out an error. My guess is 'ActiveAdmin' reads controllers my its own, not the existing ones
this is my index action path
http://localhost:3000/admin/static_contents
and this is in development mode
Can someone help me on understanding how controllers works with ActiveAdmin or am I missing something here
Following are my configs
rails (3.0.0)
ruby 1.8.7
activeadmin (0.3.2)
thanks in advance
sameera
Activeadmin controllers are not the same as your app's controllers, they are separate. The reason your code is not causing an exception from the activeadmin interface is because that code is never hit. The activeadmin controller documentation specifies how to modify the default activeadmin actions.
I want to stream a large amount of text from a controller to a view in real time and was pointed to using the following code as an example of how to handle the streaming
def home
self.response_body = proc {|resp, out|
10.times do |x|
out.write "count = #{x}"
sleep 1
end
}
Now this code works in so much the content streams to a browser with 1 line appearing every second, however it doesn’t use the home.html.erb view I created instead it only renders a blank page with the streaming data on it
I’ve tried to embed it using various bits of erb code but cant get it to work and I’ve had a hunt around the web and cant see any clue as how to do this
Can anyone help?
I'm using Rails 3.0.7 and ruby 1.9.2, in dev I'm using unicorn as the rails server which handles the streaming
Cheers
Mike
If you set the response_body in the controller it will not render the view. So I'm afraid you have to pick one or the other. In fact, I've received an exception when I tried to send a response to the client via two different methods. In my case it was send_data and self.response_body = ...
It gives me the creeps,i'm done, i need some help here, i reverted multiple times back but i can't find the error.
Simple controller (customers),a simple form for adding a customer via :remote => true and the controller does respond_to do |format| { format.js } . Works fine, renders my create.js.rjs template.
I work for a few hours without making any javascript changes or changes to my controllers or authorization etc.. and when i try it again it's not working anymore.
What i mean with not working: Controller gets called, record saved, all partials rendered. But no javascript evaluated, not even a simple alert(1) at the beginning of the file.
I tried with different prototype.js versions and different rails.js versions, but nothing helped. I hope someone has a clue about this or already experienced this.
It's not that i don't want to post code. But it won't help. Its basic code that works and, after some changes where i don't know what i really changed (some locales here, some css there, html templates from a completely different controller a bit..)..
Currently developing with: ruby 1.9.2, rails 3.0.3, prototype 1.7 RC3, rails.js from github.
SOLVED
How stupid, I missed the part where the template naming changed. My application templace was named "application.rhtml". It worked until now. As it stopped to work, I changed it to "application.html.erb" and now it's working.