Stylesheets not being recognized

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

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

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

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?

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/

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

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 :wink: ). Hope you’ll post back with more info /
your
findings. Sorry I can’t be more help at the moment.

Best regards,
Bill

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.

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

Steve wrote:

contacts.css
Thanks. It’s the damn details :wink:

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

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… :slight_smile:

Onward and upward!!!

Best regards,
Bill

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/ to request the
page, whereas there was now an 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… :slight_smile:

best,
steve

Bill W. wrote:

Steve wrote:

contacts.css
Thanks. It’s the damn details :wink:

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