where to put views for application controller?

hi,

im pretty much a rails newbie, but i was wondering where the rhtml
files go for the application controller?

i.e. if i had some logic that needed to be performed on the document
root of my website: (i.e. http://www.mysite.com)
where would i put this rhtml file.

I tried putting it in the public directory, but that failed...and the
content inside the <% %> takes weren't evaluated...

also, just entering http://www.mysite.com didn't automatically render
index.rhtml, but rather gave me a 404 error.

Hi

In your config directory is a routes.rb file which rails uses to understand which actions in your app to call in response to the url requested.

Here is what it looks like:

ActionController::Routing::
Routes.draw do |map|

The priority is based upon order of creation: first created -> highest priority.

Sample of regular route:

map.connect ‘products/:id’, :controller => ‘catalog’, :action => ‘view’

Keep in mind you can assign values other than :controller and :action

Sample of named route:

map.purchase ‘products/:id/purchase’, :controller => ‘catalog’, :action => ‘purchase’

This route can be invoked with purchase_url(:id => product.id)

You can have the root of your site routed by hooking up ‘’

– just remember to delete public/index.html.

map.connect ‘’, :controller => “welcome”

Allow downloading Web Service WSDL as a file with an extension

instead of a file named 'wsdl

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’

Install the default route as the lowest priority.

map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’
end

As you can see the first uncommented line is
map.connect ‘’, :controller => “welcome”

What this tells rails is that when the url is only http://www.mysite.com it should route that request to the welcome controller. If no action is specified rails will default to calling the index action in that controller. The index action will look for an index.rhtml, parse the <% %> into the appropriate html and deliver a html file to be served to the browser.

The last uncommented line which looks like this
map.connect ‘:controller/:action/:id’

is the default decoding of urls. the routing expects a url that looks like this for example:
http://www.mysite.com/welcome/show/5
This route mapping “decodes” the url as
:controller => ‘welcome’
:action => ‘show’
:id => 5

Hope this helps.

Ivor

thanks to both of you...thats clears things up a lot, i will start
playing with it first chance i get.

To delve a bit deeper about the structure of a rails app, is it bad
design to have only an application.rb controller? and so other
controllers.

Let me explain a bit more, basically, the site i am working on has a
lot of cgi script (thats the main chunk of the features this site
promotes), and I have the task of adding user accounts to this site
for a small additional feature. basically, at this point in time, it
seems like this will be the only feature rails will be in charge
of....so i am left wondering whats the point of putting all of my
logic in an AccountController, and having an empty
Application.rb...maybe it would make the most sense to just have
everything inside the application controller, and shorten my urls at
the same time (i.e. http://www.mysite.com/login vs. http://www.mysite.com/account/login).

This first hit me when i was adding the rails code to existing html
pages, i found that i needed to add a '../' before the images
directory in all of my <img> tags because of the fact that i was up a
level (i.e. in the account controller)