# Problem getting application.rhtml to work

**URL:** <https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223>\
**Category:** Rails\
**Created:** [November 8, 2006, 10:00am UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223 "2006-11-08T10:00:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 10:00am UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/1 "2006-11-08T10:00:14Z")

</div>

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:

 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  
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

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 10:31am UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/2 "2006-11-08T10:31:54Z")

</div>

Maybe silly question but do you have ‘layout “application”’ in  
app/controllers/application.rb?

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 10:56am UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/3 "2006-11-08T10:56:22Z")

</div>

That isn’t needed as its the default layout template.

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 1:52pm UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/4 "2006-11-08T13:52:58Z")

</div>

Hi Jordan,

Jordan wrote:

> David F. wrote:
> 
> > Maybe silly question but do you have ‘layout “application”’ in  
> > app/controllers/application.rb?
> 
> Yes, I do at the moment, but I’ve tried having it both there and not  
> there and I get the same error either way.

I know you said you’d renamed your other layouts. Have you tried  
removing  
them from the directory? I know Rails checks extensions on Views, but  
I’m  
not sure about layouts. It’s possible (and would be a bug) that it  
could  
get confused if it found a file with the ‘right’ name but the wrong  
extension. I hope you’ll let us know. I’ve never seen this problem  
before.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 11:26am UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/5 "2006-11-08T11:26:24Z")

</div>

David F. wrote:

> Maybe silly question but do you have ‘layout “application”’ in  
> app/controllers/application.rb?
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Yes, I do at the moment, but I’ve tried having it both there and not  
there and I get the same error either way.

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 5:33pm UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/6 "2006-11-08T17:33:44Z")

</div>

Thanks Bill, this was the problem!

I’d renamed all the layouts along the lines of “homepage.rhtml” -\>  
“homepage.old”. However renaming them further to “x\_homepage.old”  
solved the problem completely, giving exactly the behaviour I expected.

It does seem like rails must have been getting a bit confused - I’m  
guess having a “homepage.xxx” file in layouts made  
homepage\_controller.rb think it had its own layout, but when it  
actually went to fetch it, it couldnt find an rhtml file, so threw an  
exception. Or something like that.

Should this be reported somewhere as a bug? I’m not really familiar  
with this RoR community’s bug tracking / reporting systems yet.

Thanks again for your help,  
Jordan

---

<div class="post-metadata">

**Author:** ![Jordan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@Jordan](https://www.ruby-forum.com/u/Jordan)\
**Post date:** [November 8, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/problem-getting-application-rhtml-to-work/75223/7 "2006-11-08T18:23:51Z")

</div>

Jordan wrote:

> Thanks Bill, this was the problem!

Excellent. Thanks for letting us know.

> Should this be reported somewhere as a bug?

I would. Definitely. No telling if it will be accepted, especially if  
you  
submit it without a patch (and tests), but I’d say, at a minimum, the  
behavior needs to be recorded.

> I’m not really familiar with this RoR community’s  
> bug tracking / reporting systems yet.

No time like the present to get started 😉 The trail starts at

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

Best regards,  
Bill
