RoR: Where is the "rails/info/properties" route defined? - ruby-on-rails

I'm running Rails 2.3.4. When I create a new rails project, the public/index.html file has a link named "About your application's environment" that points to "rails/info/properties". In dev mode, it gives a summary of the runtime environment. However, in production mode, it gives a 404 page cannot be found.
Could someone point me in the direction of how and where the "rails/info/properties" route is configured? I'd just like to understand how it's set up.

The link fires off an AJAX request to rails/info/properties. The properties action is defined in the Rails::InfoController which lives in /rails/railties/builtin/rails_info/rails/info_controller.rb.
The route doesn't need to be explicitly defined because it conforms to the Rails default route of :controller/:action/:id (although there is no ID in this case and the controller lives within a Rails namespace.)

It's configured within Rails itself (when in development mode). You can probably track it down if you look through the Rails initialization code.

Related

Rails engine constants

I have a Rails engine with the latest rails and ruby.
I have a controller called cms, with a action called update. I use this update action to update different tables. For example I have got a table called setting. This technique works fine in a normal Rails app, but in my Rails Engine it throws this error:
NameError (uninitialized constant Setting):
I've got a model called Setting, why is givin me an error ?
File naming is important for autoloading to work. Naming convention is the same in both apps and engines. In fact, an application is an engine.
So, my_rails_app/app/models/cms/setting.rb is equivalent to my_engine/app/models/cms/setting.rb
If you still have troubles, try accessing constant with explicit namespace Cms::Setting.
You can dynamically get constant from an appropriate namespace by doing
Cms.const_get(table.capitalize)
However, be careful with this approach since a hacker can send you anything and hence access any constant.

Rails routing problem, action being skipped

I'm having a bizarre issue where it seems as if Rails is skipping the run of my particular Action. I have two environments that I am running this in. One (development) works fine and runs the action. The other (staging) is not running the action.
The error is that Rails can't find a template in the views directories for my given action, which is only supposed to respond with JSON (no template). I've done logging in the action and it just simply isn't being run. Rails immediately fails saying that the view doesn't exist.
Just to cover my bases, I've verified that the code is indeed the same, that my routes file is exactly the same, and that my rails version (3.0.1) is exactly the same between the two env's. Any help would be excellent here.
Apparently this comes in the department of facepalm. One of our developers had committed a new controller with a different file name but the same controller class name as another. It must be that in development rails was loading the new controller first, and so the old controller would override it and the issue was hidden. In stage however, it seems that the new controller was loaded last, which cannibalized our controller class and method, screwing everything up.
I'd be interested to know if others have encountered this problem in rails. May need to patch the controller loading code to always use the same sort mechanism (seems like file name would be most natural).

Trying to learn RoR, but keep getting Page doesn't exist errors

I'm trying to learn RoR and I keep getting pesky page doesn't exist pages. I deleted the index.html file out of my public folder and created a root route in my routes file but I still am getting that error. I am running ubuntu 10.04 with mod_passenger and ruby enterprise edition.
just leave the mod_passenger until you find the error. Do like this:
open a shell
go to your Rails app directory
ruby script/server (Rails < 3).
It should start the server in your console. and browse the page you want. If you are getting an error it should display in the console.
check your database connection is OK in config/database.yml file
rake routes is the standard shell command to see all your routes. Check if url you're trying to access is in the list. If it's not, show us statement in routes.rb you use to generate this route and url you're trying to access.
Can you please paste the content of your routes.rb file?
Also, make sure you have a controller created for that page and it should contain the index action.
def index
end

Routes not resolving in Production Environment (Rails 2.3.5)

I'm deploying my app to a live server running passenger on Apache. I've tested the app locally and my routes appear sound. I have my public controllers under app/controllers/content and my admin controllers under app/controllers/admin.
Despite everything working in the development environment i'm getting "The page you were looking for doesn't exist." error when I request http://mydomain.com/content/compare. (i.e. Content::CompareController#index).
My production log contains the lines:
Processing ContentController#compare (for 86.40.236.34 at 2010-08-14 15:03:15) [GET]
Authentication: session found, user_id is set
ActionController::UnknownAction (No action responded to compare. Actions: ):
I've called rs.recognize_path 'content/compare' and I get the error:
ActionController::RoutingError: No route matches "content/compare" with {}
The same command works with my development machine however. I've tried adding the line
map.connect 'content/:controller/:action' to the routes config file but this doesn't have any effect and I don't think it would be useful in the long run either.
Any advice on this? Seems strange that there are inconsistences between the Rails Environments.
Thanks in advance for any help,
Can we see your routes.rb file?
It appears that on your production machine it is trying to call the compare method in ContentController. Is this the method you want to be calling or is it index?
My guess is there is something wrong in your routes file. You can compare it on both environments by running rake routes.

Rails Routes Question

Did the rules for Rails Routes changes from Rails 1.2.3 to Rails 2.2.3? I recently upgraded an application and instead of redirecting to the correct page, it now redirects to the main page (or Route page) for that matter.
The only thing that I can think of is that the routing rules changed in Rails 2.2.3.
Thanks
Yep there were a lot of changes as you can see here (look at the Action Pack Resources section) "This is where the bulk of the action for 2.0 has gone". If you're using the old semi-colon syntax then that could well be the problem. Do you want to post your route config and a quick description of what is not working?
Also, to diagnose routing problems I find running "rake routes" very useful (though set your terminal window to wide).
Chris

Resources