Hey all, I have a scenario where I am loading objects to display on the screen, and they each have colors in the Model. I''d like to use these hex values to generate CSS code so I can display them cleanly, any suggestions? I saw the rcss gem and it looks like that might work, but in order to reduce the DB hit, I''d have to have a seperate CSS file that gets called *only* when a jack is being displayed so the RCSS isn''t calling the DB each time to create the CSS for the jack colors, am I right? -- - Nic --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> I have a scenario where I am loading objects to display on the > screen, and they each have colors in the Model. I''d like to use these > hex values to generate CSS code so I can display them cleanly, any > suggestions? > > I saw the rcss gem and it looks like that might work, but in order to > reduce the DB hit, I''d have to have a seperate CSS file that gets > called *only* when a jack is being displayed so the RCSS isn''t calling > the DB each time to create the CSS for the jack colors, am I right?Why do it by generating a new css file? You can just add ''style="color: #mycolor"'' to the elements that need dynamic coloring. You can then use the rails caching to lighten the load. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 25 Aug 2006, at 08:40, Peter De Berdt wrote:>> I have a scenario where I am loading objects to display on the >> screen, and they each have colors in the Model. I''d like to use these >> hex values to generate CSS code so I can display them cleanly, any >> suggestions? >> >> I saw the rcss gem and it looks like that might work, but in order to >> reduce the DB hit, I''d have to have a seperate CSS file that gets >> called *only* when a jack is being displayed so the RCSS isn''t >> calling >> the DB each time to create the CSS for the jack colors, am I right? > > Why do it by generating a new css file? You can just add > ''style="color: #mycolor"'' to the elements that need dynamic > coloring. You can then use the rails caching to lighten the load.It''s not very good practice to put styles within HTML, assuming this is what you were getting at. ------ Alastair Moore Standards compliant web development with Ruby On Rails, PHP and ASP www.kozmo.co.uk 07738 399038 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 25 Aug 2006, at 11:27, Alastair Moore wrote:> > On 25 Aug 2006, at 08:40, Peter De Berdt wrote: > >>> I have a scenario where I am loading objects to display on the >>> screen, and they each have colors in the Model. I''d like to use >>> these >>> hex values to generate CSS code so I can display them cleanly, any >>> suggestions? >>> >>> I saw the rcss gem and it looks like that might work, but in >>> order to >>> reduce the DB hit, I''d have to have a seperate CSS file that gets >>> called *only* when a jack is being displayed so the RCSS isn''t >>> calling >>> the DB each time to create the CSS for the jack colors, am I right? >> >> Why do it by generating a new css file? You can just add >> ''style="color: #mycolor"'' to the elements that need dynamic >> coloring. You can then use the rails caching to lighten the load. > > It''s not very good practice to put styles within HTML, assuming > this is what you were getting at.Sure, I totally agree, but as I said before, if it''s for the better, you sometimes need to bend the rules a bit. Generating dynamic css will have the browser reload the whole css every time around instead of using the locally cached version. Not really very efficient, as 95% of the css file will be identical. Now you have two options: split up your css file in a static part (that can be cached) and a dynamic one (which will generate another request to the server each time around) or just use styling in your XHTML file. I tend to favor the last option, because it doesn''t need yet another plugin. Also remember that if you''re planning to use scriptaculous visual effects, you''ll have to use the style attribute anyway (display: none;). Like always, extremism leads nowhere :-) Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Peter De Berdt wrote:> Now you have two options: split up your css file in a static part > (that can be cached) and a dynamic one (which will generate another > request to the server each time around) or just use styling in your > XHTML file. I tend to favor the last option, because it doesn''t need > yet another plugin. Also remember that if you''re planning to use > scriptaculous visual effects, you''ll have to use the style attribute > anyway (display: none;).I agree, that is the best approach. The only minor change I would do is to instead using inline styles, use the <style /> tag in header. You can put all variable CSS selectors there and not clutter the html itself. Dynamically generated CSS files were in fact doubling the load on the server so I removed them entirely from development version of RCSS[1]. Cheers, Bragi [1] http://rcss.rubyforge.org -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---