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 <style>...</style> code is still being included from somwhere. Where? What am I missing? thanks, steve -- Posted via http://www.ruby-forum.com/.
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 <style>...</style> code is still > being included from somwhere.What do you mean by "inline"? If, in fact, you''ve got <style> 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: <html> <head> <title>Contacts: <%= controller.action_name %></title> </head> <body> <p style="color: green"><%= flash[:notice] %></p> <%= @content_for_layout %> </body> </html> Nevertheless, the following is rendered into the /contact/ request result: ... <html> <head> <title>Scaffolding</title> <style> 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 <style>...</style> code from between the <head> 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 <style>...</style> code is still >> being included from somwhere. > > What do you mean by "inline"? If, in fact, you''ve got <style> 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 <head><style>...</style></head> 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 -- Posted via http://www.ruby-forum.com/.
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? -- Posted via http://www.ruby-forum.com/.
Jason Pfeifer 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: <h1>Listing contacts</h1> <table> <tr><% for column in Contact.content_columns %> <th><%= column.human_name %></th> <% end %> </tr> <% for contact in @contacts %><tr> <% for column in Contact.content_columns %><td><%=h contact.send(column.name) %></td><% end %><td><%= link_to ''Show'', :action => ''show'', :id => contact %></td><td><%= link_to ''Edit'', :action => ''edit'', :id => contact %></td><td><%= link_to ''Destroy'', { :action => ''destroy'', :id => contact }, :confirm => ''Are you sure?'' %></td></tr> <% end %> </table> <%= 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 %> <br /><%= 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... -- Posted via http://www.ruby-forum.com/.
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: > > <html> > <head> > <title>Contacts: <%= controller.action_name %></title>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: > ... > <html> > <head> > <title>Scaffolding</title>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.> <style> > 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
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 Walton 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: >> >> <html> >> <head> >> <title>Contacts: <%= controller.action_name %></title> > > 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 <style> 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 -- Posted via http://www.ruby-forum.com/.
Steve wrote:>> 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 <style> code into the head of the returned html. > > Yes. scaffold.css is the ''global'' css file I mistakenly referred to as > contacts.cssThanks. 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 <title>Contacts: <%= controller.action_name %></title>, then there''s *no* way you should be getting the <title>Scaffolding</title> resulting html. Totally wierd. Best regards, Bill
Guest - Steve Ball
2006-Jun-03 02:03 UTC
[Rails] Re: Re: Re: Stylesheets not being recognized
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... :) best, steve Bill Walton 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 <title>Contacts: <%= controller.action_name %></title>, then > there''s *no* way you should be getting the <title>Scaffolding</title> > resulting html. Totally wierd. > > Best regards, > Bill-- Posted via http://www.ruby-forum.com/.
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