Hi guys,
I'm a day into working on my very first Ruby on Rails app, so this is probably something really silly I've overlooked.
I just want to get my entire app using a single layout (for now, at least). Going by what came up from google searching, I created
/app/views/layouts/application.rhtml
which looks something like this:
<head> <title>Whelps - <%= ["In the ", controller.controller_name, " section viewing the ", controller.action_name, " page."] %></title> <%= stylesheet_link_tag 'scaffold' %> </head> <body>
<!-- TODO: Header! Include navigation partail--> <p style="color: green"><%= flash[:notice] %></p>
<%= yield %> <br /> <!-- Footer --> <hr /> <br /> <p> Have any problems, questions, or suggestions on Whelps?<br /> We'd greatly appreciate your <%= link_to "feedback", :controller => "feedback" %><br /> <br /> <small><em>Powered by <%= link_to "Ruby on Rails", :url => "http://www.rubyonrails.org" %><br /> © Jordan Rastrick, 2006</em></small><br /> </p> </body> </html>
It works fine and dandy if I specify layout "application" at the beginning of my controllers. However, if I don't specify this line at the top of a given controller, I get an error when trying to reach it.
For example, theres the trivial app/views/controllers/homepage_controller.rb:
class HomepageController < ApplicationController def user_permitted?(user) return true # Every user is permitted to visit their homepage end
def index
end end
Trying to access /homepage gives:
ActionView::ActionViewError in HomepageController#index
No rhtml, rxml, rjs or delegate template found for layouts/homepage
However, from what I'd read, I'd been lead to believe that "application.rhtml" would be used (by defaut) by the Application Controller, and then this would be inherited by all controllers decending from it (all my controllers do). I've renamed all the other files in app/views/layouts, so that application.rhtml is the only rhtml file present.
I know, its only a minor annoyance, but it seems to go against the whole spirit of Rails (esp. DRY) that I'd have to specify the exact same default layout in every single controller, so I figure I must be doing something wrong somewhere. Perhaps the inheriting of layouts behaviour has been deprecated, and/or replaced with something better? The Rails API didn't offer any clues on this front.
Any pointers would be greatly appreciated.
Thanks, Jordan Rastrick