The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Linking to Home

I'm having the darnedest time understanding something I'm sure is very simple (at least was under other web dev platforms where I would do a href...C:\windows\apps\home.html). I'm trying to set up a link to my home page

I have an application controller:

Code:

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
layout "main"
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
end

I would like home to display the contents of my main.html.erb file. (or should it be application.html.erb?). To further confuse me, my home folder, under /apps/views/home has an index.html.erb file.

I must be mixing up my views (have I somehow created too many?) and perhaps not defining things properly in routes.rb. Hopefully haven't confused you all as much as I have myself. Any help most appreciated.

The HomeController is going to display the views contained within the app/views/home folder. index.html.erb is the default view that will be displayed when the url looks like this: localhost:3000/home.

If you want to define a default controller/view for your app you would want to put something like this in your routes.rb:

Code:

map.root :controller => "home", :action => "index"

If you do this, make sure to delete the index.html file in the public folder.

The HomeController is going to display the views contained within the app/views/home folder. index.html.erb is the default view that will be displayed when the url looks like this: localhost:3000/home.

If you want to define a default controller/view for your app you would want to put something like this in your routes.rb:

Code:

map.root :controller => "home", :action => "index"

If you do this, make sure to delete the index.html file in the public folder.

Thanks!!

Ok, that got my main view to appear, but minus some of the html. It displays the header and footer, but none of the other div content. Do I have another file/association mixup of some type?

and assuming main.html.erb is the layout template for the entire site, (not application.html.erb), how to I properly format the link_to statement?

That code will be inserted into the application.html.erb and the page will be rendered to the browser.

Designing your app like this may save you some frustrations. Hope this helps.

I think I'd created main.html.erb after reading one too many tutorials :-) In any case, I did delete it, copying that code to application.html.erb. How do I format the link_to code for the Home button on my navigation?