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
which looks something like this:Whelps - <%= ["In the ", controller.controller_name, " section viewing the ", controller.action_name, " page."] %> <%= stylesheet_link_tag 'scaffold' %>
<%= flash[:notice] %>
<%= yield %>
Have any problems, questions, or suggestions on Whelps?
We'd greatly appreciate your <%= link_to "feedback", :controller => "feedback" %>
Powered by <%= link_to "Ruby on Rails", :url => "http://www.rubyonrails.org" %>
© Jordan Rastrick, 2006
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
class HomepageController < ApplicationController
return true # Every user is permitted to visit their homepage
def index 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
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.