# Layout antics

**URL:** <https://www.ruby-forum.com/t/layout-antics/166958>\
**Category:** Rails\
**Created:** [May 1, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/layout-antics/166958 "2009-05-01T12:29:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 1, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/layout-antics/166958/1 "2009-05-01T12:29:03Z")

</div>

I have a strange problem with my layout file. I think it may be due to  
nested partials, but removing the deepest nested partial call does not  
clear the problem.

I have an application wide layout (application.html.erb) that works as  
expected - loads images, javascript, css etc for my application.

So [http://localhost:3000/patients](http://localhost:3000/patients) → fine  
[http://localhost:3000/patients/new](http://localhost:3000/patients/new) → fine  
[http://localhost:3000/operations](http://localhost:3000/operations) → fine  
[http://localhost:3000/operations/new](http://localhost:3000/operations/new) → problems

The problem is that rails is suddenly confused about paths and  
interprets:

\<link href=“css/menu.css” rel=“stylesheet” type=“text/css” /\>

As routing calls. (from the stderror output):

Processing OperationsController#css to css (for 127.0.0.1 at  
2009-05-01 06:07:26) [GET]  
Parameters: {“id”=\>“menu”}

ActionController::UnknownAction (No action responded to css. Actions:  
access\_denied, check\_group, check\_roles, create, destroy, edit, index,  
new, role\_requirements, role\_requirements=, show, toggle, and update):

Does anyone have an idea of where to look or have you seen this error  
before?

Nothing dynamic is changing in the layout file to my knowledge. This  
error occurs if I call that page directly, or if I get there through  
the application (operations belong to patients, patients have many  
operations).

---

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 1, 2009, 6:20pm UTC](https://www.ruby-forum.com/t/layout-antics/166958/2 "2009-05-01T18:20:42Z")

</div>

dwormuth wrote:

> [http://localhost:3000/operations/new](http://localhost:3000/operations/new) → problems
> 
> The problem is that rails is suddenly confused about paths and  
> interprets:
> 
> \<link href=“css/menu.css” rel=“stylesheet” type=“text/css” /\>

I’d try using an absolute path i.e: “/css/menu.css”

HTH

~Matt

---

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 1, 2009, 6:43pm UTC](https://www.ruby-forum.com/t/layout-antics/166958/3 "2009-05-01T18:43:21Z")

</div>

Matt H. wrote:  
[…]

> I’d try using an absolute path i.e: “/css/menu.css”
> 
> HTH
> 
> ~Matt

Better yet, use stylesheet\_link\_tag – that way Rails will construct the  
proper path and save you some typing.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 2, 2009, 10:01am UTC](https://www.ruby-forum.com/t/layout-antics/166958/4 "2009-05-02T10:01:56Z")

</div>

dwormuth wrote:  
[…]

> I’d really like to understand why the layout works for some  
> controller/actions and not for others.

Most likely because you had a relative URL that worked with respect to  
/operations, but not with respect to /operations/new (which is one level  
deeper in the virtual directory hierarchy that Rails creates). Notice  
that the absolute path for your CSS file works in all cases.

This is fundamental to all Web development. If you don’t understand the  
difference between absolute and relative paths, then go study some more,  
because it’s essential that you understand it. If you _do_ understand  
it, then be aware that it works in Rails the same as it does anywhere  
else (except that most of the directories are virtual).

Does that help?

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 2, 2009, 12:06am UTC](https://www.ruby-forum.com/t/layout-antics/166958/5 "2009-05-02T00:06:45Z")

</div>

The hard coded url fixed the problem. I’ll try the stylesheet\_link tag  
next. I’d really like to understand why the layout works for some  
controller/actions and not for others.

Thanks for the help

Dave

On May 1, 12:43 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![dwormuth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d2c977/32.png) [@dwormuth](https://www.ruby-forum.com/u/dwormuth)\
**Post date:** [May 2, 2009, 6:53pm UTC](https://www.ruby-forum.com/t/layout-antics/166958/6 "2009-05-02T18:53:18Z")

</div>

Thanks, I was considering “new” as the same level as “index”, but see  
how this makes a difference.

Dave

On May 2, 4:01 am, Marnen Laibow-Koser \<rails-mailing-l…@andreas-
