# Stylesheets not being recognized

**URL:** <https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242>\
**Category:** Rails\
**Created:** [June 1, 2006, 8:19pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242 "2006-06-01T20:19:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 8:19pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/1 "2006-06-01T20:19:34Z")

</div>

I am a newbie, but have worked through 4 or 5 tutorials. I am using  
InstantRails. The problem is that I cannot determine how the style is  
being included. I have modified the stylesheet from  
/public/stylesheets/, even removed it. All to no avail. The inline

... code is still being included from somwhere. Where? 

What am I missing?

thanks,  
steve

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 8:46pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/2 "2006-06-01T20:46:04Z")

</div>

Hi Steve,

Steve wrote:

> I cannot determine how the style is  
> being included.

If you’re generating scaffold code, you’ll find the stylesheet linked by  
name in your layout file.

> I have modified the stylesheet from  
> /public/stylesheets/, even removed it.  
> All to no avail.

What exactly do you mean “to no avail”? If you’ve deleted all the  
stylesheets in /public/stylesheets, what is it you’re seeing that makes  
you  
sure _any_ style is being applied?

> The inline … code is still  
> being included from somwhere.

What do you mean by “inline”? If, in fact, you’ve got tags in  
your  
code, that styling will over-ride any external stylesheet as it’s  
supposed  
to according to the W3C standard.

Sorry I can’t help more at this point. More info needed.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/3 "2006-06-01T22:09:01Z")

</div>

Hi Bill, nice to hear from you again…

> If you’re generating scaffold code, you’ll find the stylesheet linked by  
> name in your layout file.

Yes, I generated scaffold code. I have an app, contact, based on the  
“Fast-track your Web apps with Ruby on Rails” by David Mertz IBM  
article.

> > I have modified the stylesheet from  
> > /public/stylesheets/, even removed it.  
> > All to no avail.

There is no effect on rendering no matter what I do with the  
/views/layouts/contacts.rhtml file

Viz below: no style argument:

Contacts: \<%= controller.action\_name %\>

\<%= flash[:notice] %\>

\<%= @content\_for\_layout %\>

Nevertheless, the following is rendered into the /contact/ request  
result:

…

 Scaffolding body { background-color: #fff; color: #333; }

```
body, p, ol, ul, td {
  font-family: verdana, arial, helvetica, sans-serif;
  font-size: 13px;
  line-height: 18px;
}

```

…

> What exactly do you mean “to no avail”? If you’ve deleted all the  
> stylesheets in /public/stylesheets, what is it you’re seeing that makes  
> you  
> sure _any_ style is being applied?

There is no affect on the rendering style, no matter what I do. I also  
placed my own css code into the default style sheet (contact.css) and it  
had no affect on the rendering.

By removing the … code from between the tags in  
the generated html page, and viewing in browser, it renders with default  
browser style (no css style) and the difference is obvious.

> > The inline … code is still  
> > being included from somwhere.
> 
> What do you mean by “inline”? If, in fact, you’ve got tags in  
> your  
> code, that styling will over-ride any external stylesheet as it’s  
> supposed  
> to according to the W3C standard.

That is correct and what I would expect. That’s why I am flamoozled in  
trying to figure out where/how this … code  
is inserted into the request result, since I want to modify it, and when  
I make the modifications they have no effect. The ‘original’ style code  
continues to render into the head section, overriding any possible  
changes I make in the ‘global’ css, or even deleting it. And not  
referencing it in the layout.

Hope this clarifies the issue!

regards,  
Steve

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 10:19pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/4 "2006-06-01T22:19:30Z")

</div>

That sounds really strange…

My first guess in listening would be to ask: is the stylesheet cached  
maybe?  
and are you actually generating the scaffolds or are you declaring a  
runtime scaffold? ( scaffold :model )

More than anything this has got to be a simple quirk or something, I’ve  
never had any problems with stylesheets at all. Are you using an IDE?

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/5 "2006-06-01T22:47:50Z")

</div>

Jason P. wrote:

> That sounds really strange…
> 
> My first guess in listening would be to ask: is the stylesheet cached  
> maybe?  
> and are you actually generating the scaffolds or are you declaring a  
> runtime scaffold? ( scaffold :model )
> 
> More than anything this has got to be a simple quirk or something, I’ve  
> never had any problems with stylesheets at all. Are you using an IDE?

Yes, indeed. I did think of caching issue right off, and cleared all  
cache, even restarted the app.

Actually generating the scaffolds via ‘ruby script/generate scaffold  
Contact’.

for example:

# Listing contacts
\<% for column in Contact.content\_columns %\> \<% end %\> \<% for contact in @contacts %\> \<% for column in Contact.content\_columns %\>\<% end %\> \<% end %\>

| \<%= column.human\_name %\> |
| --- |
| \<%=h contact.send(column.name) %\> | \<%= link\_to 'Show', :action =\> 'show', :id =\> contact %\> | \<%= link\_to 'Edit', :action =\> 'edit', :id =\> contact %\> | \<%= link\_to 'Destroy', { :action =\> 'destroy', :id =\> contact }, :confirm =\> 'Are you sure?' %\> |

\<%= link\_to 'Previous page', { :page =\> @contact\_pages.current.previous } if @contact\_pages.current.previous %\>\<%= link\_to 'Next page', { :page =\> @contact\_pages.current.next } if @contact\_pages.current.next %\>  
\<%= link\_to 'New contact', :action =\> 'new' %\>

In fact, if you look at the article in  
[http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/](http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/)

=\> search for the heading ‘Creating customizable content’

This is where I am de-railed: a few paragraphs down we see:

“Now there’s a bit more to work with, so try modifying a few things.  
(Notice that this code has gone back to the plural form contacts, for  
reasons not clear to me; we need to accept it for now.) Try changing a  
few colors and fonts in the CSS:”

This is what I was doing, and NOTHING! I referenced InstantRails  
because I was suspicious that perhaps something in this platform is  
‘managing’ the style include somehow.

Don’t get me wrong: I love the InstantRails platform. It’s completely  
portable, doesn’t interfere with anything else running on the local, and  
allows you to easily poke around and learn.

But I’m stumped on this style issue…

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/6 "2006-06-01T23:16:41Z")

</div>

Steve wrote:

> Hi Bill, nice to hear from you again…

Thanks, Steve. Likewise.

> There is no effect on rendering no matter what  
> I do with the /views/layouts/contacts.rhtml file
> 
> Viz below: no style argument:
> 
> Contacts: \<%= controller.action\_name %\>

Scaffolding (i.e., ruby script\generate scaffold Model Controller)  
generates  
a line that’s missing here (\<%= stylesheet\_link\_tag ‘scaffold’ %\>).  
That’s  
what tell’s Rails what stylesheet to use. Did you remove it?

> Nevertheless, the following is rendered into the /contact/ request  
> result:  
> …
> 
> Scaffolding

This looks like trouble. The title _should_ be (per the line in  
contacts.rhtml) something that starts with 'Contacts: ", this is  
definitely  
where I’d be digging. Do you have a method named ‘Scaffolding’ in  
contacts\_controller.rb? If so, I’d recommend renaming it and see what  
happens. I would not be a bit surprised to find that its use as a  
method  
name caused unexpected results. OTOH, I did a little sandbox test  
myself  
and couldn’t reproduce your results.

> body { background-color: #fff; color: #333; } body, p, ol, ul, td {

```
  font-family: verdana, arial, helvetica, sans-serif;
  font-size: 13px;
  line-height: 18px;
}

```

…  
Interesting. This is also the content of scaffold.css.

> I also placed my own css code into the default  
> style sheet (contact.css)

I’m not sure what you mean by ‘default’ here. The style sheet Rails  
generates / uses by default is called ‘scaffold.css’. You can replace  
and/or augment that (i.e., you can specify a different style sheet or  
more  
than one style sheet) in the stylesheet\_link\_tag, but since the code  
above  
doesn’t have a stylesheet\_link\_tag …

As far as that goes, I have no idea how, without explicitly trying to,  
you’re getting style tags embedded in your html page. I’m not familiar  
with  
the tutorial you’re working on but… any chance you’ve got a  
@content\_for\_header variable anywhere in the code?

It’s an interesting problem (but then, _anything’s_ interesting if it’s  
not  
happening to one’s self 😉 ). Hope you’ll post back with more info /  
your  
findings. Sorry I can’t be more help at the moment.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 1, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/7 "2006-06-01T23:51:16Z")

</div>

Steve wrote:

> (Notice that this code has gone back to the plural form  
> contacts, for reasons not clear to me;

Just as an FYI, the reason for the contacts\_controller and contracts  
view  
directory is that he didn’t specify a controller name in his scaffold  
command.

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 2, 2006, 1:11am UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/8 "2006-06-02T01:11:20Z")

</div>

Bill W. wrote:

> Steve wrote:
> 
> > Hi Bill, nice to hear from you again…
> 
> Thanks, Steve. Likewise.
> 
> > There is no effect on rendering no matter what  
> > I do with the /views/layouts/contacts.rhtml file
> > 
> > Viz below: no style argument:
> > 
> > Contacts: \<%= controller.action\_name %\>
> 
> Scaffolding (i.e., ruby script\generate scaffold Model Controller)  
> generates  
> a line that’s missing here (\<%= stylesheet\_link\_tag ‘scaffold’ %\>).  
> That’s  
> what tell’s Rails what stylesheet to use. Did you remove it?

Yes, indeed. I removed it in order to force at least _no_ style  
application. Surprise. Even without the argument to scaffold.css it  
still renders the code into the head of the returned html.

Yes. scaffold.css is the ‘global’ css file I mistakenly referred to as  
contacts.css

I’ll check into the other items you mention at the earliest opportunity.  
Probably not today.

I really appreciate you walking through this issue. I continue to  
learn.

Will get to the bottom of it…

steve

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 2, 2006, 2:59am UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/9 "2006-06-02T02:59:46Z")

</div>

Steve wrote:

> contacts.css  
> Thanks. It’s the damn details 😉

> I really appreciate you walking through this issue. I continue to  
> learn.

Thank you for hanging in there!!! We’re all still learning!!!

> Will get to the bottom of it…

Definitely looking forward to it. Like I said before… if your view  
file  
really says Contacts: \<%= controller.action\_name %\>, then  
there’s _no_ way you should be getting the Scaffolding  
resulting html. Totally wierd.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 3, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/10 "2006-06-03T17:37:20Z")

</div>

Steve Ball wrote:

> Solved.

Excellent! And thanks for the update. It’s really good form, IMO, when  
folks take the time to post here to document the solution they’ve found.  
Makes it easier for the next newbie. That’s what it’s is all about.

> On to the next stoplight… 🙂

Onward and upward!!!

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [June 3, 2006, 4:03am UTC](https://www.ruby-forum.com/t/stylesheets-not-being-recognized/62242/11 "2006-06-03T04:03:00Z")

</div>

Solved. Well, it definitely had to do with the ‘create a view’ behavior  
of the scaffold script (which the author mentioned and you commented  
upon): “Just as an FYI, the reason for the contacts\_controller and  
contracts [sic] view directory is that he didn’t specify a controller  
name in his scaffold command.”

The bottom line was I was using [http://myapp/contact/](http://myapp/contact/) to request the  
page, whereas there was now an [http://myapp/contacts/](http://myapp/contacts/) [plural] folder in  
views, with the style pointer to scaffold.css. So I was making all  
these mods to the scaffold.css, but the code was being generated on the  
fly based on my request to the earlier created views/contact (via  
script/generate controller contact).

Confusing yes. It got me even when the phenomena was pointed out in the  
article. However, it provided a path to understanding. Now I am going  
to _specify_ the controller name and manage this correctly.

This was just a minor stopsign, and I thank you for your help and  
patience.

On to the next stoplight… 🙂

best,  
steve

Bill W. wrote:

> Steve wrote:
> 
> > contacts.css  
> > Thanks. It’s the damn details 😉
> 
> > I really appreciate you walking through this issue. I continue to  
> > learn.
> 
> Thank you for hanging in there!!! We’re all still learning!!!
> 
> > Will get to the bottom of it…
> 
> Definitely looking forward to it. Like I said before… if your view  
> file  
> really says Contacts: \<%= controller.action\_name %\>, then  
> there’s _no_ way you should be getting the Scaffolding  
> resulting html. Totally wierd.
> 
> Best regards,  
> Bill
