# Application Errors w/ layout & custom view pages

**URL:** <https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468>\
**Category:** Rails\
**Created:** [December 31, 2005, 9:39pm UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468 "2005-12-31T21:39:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [December 31, 2005, 9:39pm UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/1 "2005-12-31T21:39:04Z")

</div>

1. I get Rails Application Error when trying to use layout

test\_controller  
def list  
layout “stdlayout”  
end

in the views/test/layouts stdlayout.rhtml

test
# Test
\<%= content\_for\_layout %\>
1. I get Rails Application Error when trying to use a separate display  
page

I create a method in the test\_controller  
def welcome  
end

in test/views I create an html page called welcome.rhtml

what am I missing ? thanks.

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [December 31, 2005, 9:57pm UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/2 "2005-12-31T21:57:08Z")

</div>

John,

I believe you want to use \<%= @content\_for\_layout %\> and not  
‘content\_for\_layout.’

I also believe the method #layout is a class method that shouldn’t be  
placed inside an action:

class TestController  
layout ‘stdlayout’  
…  
actions go here…

If you want to have a specific layout for an action, try (for the API):

def help  
render :action =\> “help/index”, :layout =\> “help”  
end

- Derek

On 12/31/05, John T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Derek H.  
HighGroove Studios - [http://www.highgroove.com](http://www.highgroove.com)  
Atlanta, GA  
Keeping it Simple.  
404.593.4879

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 1, 2006, 12:27am UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/3 "2006-01-01T00:27:22Z")

</div>

Thanks, but neither the layouts or custom html pages are working - still  
getting application errors (vers. 1.0 and ruby 1.8.3 ubuntu). Something  
seems really wrong not to be able to do these things after spending  
hours with it. I’m either really missing something or maybe rails is  
still too fragile/inflexible for our needs at this point.

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 1, 2006, 1:00am UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/4 "2006-01-01T01:00:26Z")

</div>

What is the trace of the ApplicationError? Without that, it’s pretty  
tough to figure out what’s wrong.

- Derek

On 12/31/05, John T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ‘content\_for\_layout.’
> > 
> > > test\_controller
> > > 
> > > what am I missing ? thanks.
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Derek H.  
HighGroove Studios - [http://www.highgroove.com](http://www.highgroove.com)  
Atlanta, GA  
Keeping it Simple.  
404.593.4879

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 1, 2006, 12:31pm UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/5 "2006-01-01T12:31:21Z")

</div>

Thanks all for suggestions. Actually the layout is in views/layouts - I  
just mistyped in email. I have shown vital info & log below. The  
default scaffold list without layout works fine. I get similar error  
when trying to use a separate/custom page (ie welcome, help, … etc)  
beyond the standard scaffold stuff. And I cannot find any examples of  
such.

class AgenciesController \< ApplicationController  
layout ‘stdlayout’

def index  
list  
render :action =\> ‘list’  
end  
def list  
@agency\_pages, @agencies = paginate :agencies, :per\_page =\> 10  
end

…/app/views/layouts/stdlayout.rhtml

test
# login screen
 \<%= @content\_for\_layout %\>

Processing AgenciesController#index (for 127.0.0.1 at 2005-12-31  
15:59:08) [GET]  
Parameters: {“action”=\>“index”, “controller”=\>“agencies”}  
e[4;36;1mAgency Count (0.001912)e[0m e[0;1mSELECT COUNT(\*) FROM  
agencies e[0m  
e[4;35;1mAgency Load (0.000740)e[0m e[0mSELECT \* FROM agencies  
LIMIT 10 OFFSET 0e[0m  
Rendering actionlistlayoutfalse within layouts/stdlayout  
Rendering agencies/list  
e[4;36;1mSQL (0.004213)e[0m e[0;1m SELECT a.attname,  
format\_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull  
FROM pg\_attribute a LEFT JOIN pg\_attrdef d  
ON a.attrelid = d.adrelid AND a.attnum = d.adnum  
WHERE a.attrelid = ‘agencies’::regclass  
AND a.attnum \> 0 AND NOT a.attisdropped  
ORDER BY a.attnum  
e[0m

Steven S. wrote:

> In the case of 1) the layout should be in app\>views\>layouts, not  
> app\>views\>test\>layouts and as pointed out in another reply, layout  
> should be at the class level, not inside a method and you want  
> @content\_for\_layout not content\_for\_layout. For 2), what error are you  
> getting specifically? What’s in your development.log?

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 1, 2006, 3:30am UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/6 "2006-01-01T03:30:44Z")

</div>

In the case of 1) the layout should be in app\>views\>layouts, not  
app\>views\>test\>layouts and as pointed out in another reply, layout  
should be at the class level, not inside a method and you want  
@content\_for\_layout not content\_for\_layout. For 2), what error are  
you getting specifically? What’s in your development.log?

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 2, 2006, 5:16am UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/7 "2006-01-02T05:16:17Z")

</div>

Steven S. wrote:

> What are the names of your models / tables used with this controller /  
> action?

table: agencies model: agency.rb (class Agency)

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [January 1, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/application-errors-w-layout-custom-view-pages/51468/8 "2006-01-01T22:10:40Z")

</div>

What are the names of your models / tables used with this  
controller / action?

Thanks.
