# Components and layouts

**URL:** <https://www.ruby-forum.com/t/components-and-layouts/48197>\
**Category:** Rails\
**Created:** [November 17, 2005, 5:57pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197 "2005-11-17T17:57:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 5:57pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/1 "2005-11-17T17:57:21Z")

</div>

Is there anyway for a component to use the layouts availble to rest of  
the app, but still use the templates under its own directory? Setting  
the layout with a “layouts/admin” say, just produces “can not find  
admin.rhtml…”. Is there anyway around this?

If not I guess I could just put the views under app/views, but really  
wanted to keep things seperate.

Thanks!  
-Nick

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 6:06pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/2 "2005-11-17T18:06:23Z")

</div>

I try to call up images in my browser from my  
public/images directory and get a routing error.

Here is my path

[http://localhost:3000/images/logo.jpg](http://localhost:3000/images/logo.jpg)

And the error

Routing Error

Recognition failed for “/images/logo.jpg”

Any ideas why this would be happening?

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 9:26pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/3 "2005-11-17T21:26:11Z")

</div>

On Thursday 17 November 2005 23:56, Nick S. wrote:

> Is there anyway for a component to use the layouts availble to rest  
> of the app, but still use the templates under its own directory?  
> Setting the layout with a “layouts/admin” say, just produces “can  
> not find admin.rhtml…”. Is there anyway around this?
> 
> If not I guess I could just put the views under app/views, but  
> really wanted to keep things seperate.  
> Can symlink be an easy way out?  
> Btw, I’ve tried to supply full path to layout method, like  
> “#{RAILS\_ROOT}app/views/layouts/blah.rhtml” but with no success. I  
> wonder why so…

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 9:56pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/4 "2005-11-17T21:56:24Z")

</div>

Symlinking wont work in this case, its gotta be deployable on a windows  
box,

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 9:41pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/5 "2005-11-17T21:41:18Z")

</div>

On Friday 18 November 2005 00:04, jonathan Mcintire wrote:

> Recognition failed for “/images/logo.jpg”
> 
> Any ideas why this would be happening?  
> Are you sure logo.jpg is in public/images? And make sure the  
> permissions are correct.

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 17, 2005, 11:10pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/6 "2005-11-17T23:10:08Z")

</div>

I had a similar problem and turned out my path to the image was missing  
a slash.

Example:

I had:

images/logo.gif

and Rails needed

/images/logo.gif

Not sure if it is the same for you or not, but you can give it a shot.

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 18, 2005, 6:01pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/7 "2005-11-18T18:01:52Z")

</div>

Not quite. All the stuff under /public is working fine and as it  
should. My problem is that if I have views under  
/components/my\_component/comp/index.rhtml  
It can’t access a layout under /app/views/layouts/admin.rhtml

For now I’ve moved the views of the components under app/views but  
this kind of defeats the purpose in my mind.

Any other ideas on this?

-Nick

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 18, 2005, 10:00pm UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/8 "2005-11-18T22:00:20Z")

</div>

Hi Nick,

On 11/18/05, Nick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Not quite. All the stuff under /public is working fine and as it  
> should. My problem is that if I have views under  
> /components/my\_component/comp/index.rhtml  
> It can’t access a layout under /app/views/layouts/admin.rhtml
> 
> For now I’ve moved the views of the components under app/views but  
> this kind of defeats the purpose in my mind.
> 
> Any other ideas on this?

I am using Subversion and I have solved this problem by using  
“svn:external”  
property to link components/layouts to /app/views/layouts. Not very  
beautiful solution but works on Windows.

Best regards,

Luben

---

<div class="post-metadata">

**Author:** ![nicholas.stuart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@nicholas.stuart](https://www.ruby-forum.com/u/nicholas.stuart)\
**Post date:** [November 20, 2005, 12:21am UTC](https://www.ruby-forum.com/t/components-and-layouts/48197/9 "2005-11-20T00:21:54Z")

</div>

Interesting idea Luben. This might be the route I go, but it looks  
like there is no ‘offical’ way to handle this. Guess I’ll have open up  
an enhancement request then…

Thanks again!  
-Nick
