How can I link to a CSS file in one of my view files? -- Posted via http://www.ruby-forum.com/.
>How can I link to a CSS file in one of my view files?Typically you do this in your layouts: <%= stylesheet_link_tag "filename", :media => "all" %> More here: http://rails.rubyonrails.com/classes/ActionView/Helpers/ AssetTagHelper.html#M000397 -- Posted with http://DevLists.com. Sign up and save your time!
Andrew Otwell wrote:>>How can I link to a CSS file in one of my view files? > > Typically you do this in your layouts: > > <%= stylesheet_link_tag "filename", :media => "all" %> > > More here: http://rails.rubyonrails.com/classes/ActionView/Helpers/ > AssetTagHelper.html#M000397Thanks :) -- Posted via http://www.ruby-forum.com/.
Andrew Otwell wrote:>>How can I link to a CSS file in one of my view files? > > Typically you do this in your layouts: > > <%= stylesheet_link_tag "filename", :media => "all" %> > > More here: http://rails.rubyonrails.com/classes/ActionView/Helpers/ > AssetTagHelper.html#M000397I just tried this and in the source it is looking for /stylesheets/filename. In RadRails you cannot create folders, so I created the folder in explorer and moved the style.css file into that folder, but it still is not reading it. Also, I have changed filename to style.css. Thanks :) -- Posted via http://www.ruby-forum.com/.
On 2/11/06, Michael Boutros <me@michaelboutros.com> wrote:> I just tried this and in the source it is looking for > /stylesheets/filename. In RadRails you cannot create folders, so IFalse: Right click, choose New, Other, Simple, and choose Folder.> created the folder in explorer and moved the style.css file into that > folder, but it still is not reading it. Also, I have changed filename to > style.css. Thanks :)It''s looking in the "public/stylesheets/" directory in the root of your Rails app. Tony
Tony Collen wrote:> On 2/11/06, Michael Boutros <me@michaelboutros.com> wrote: > >>I just tried this and in the source it is looking for >>/stylesheets/filename. In RadRails you cannot create folders, so I > > > False: Right click, choose New, Other, Simple, and choose Folder. > > >>created the folder in explorer and moved the style.css file into that >>folder, but it still is not reading it. Also, I have changed filename to >>style.css. Thanks :) > > > It''s looking in the "public/stylesheets/" directory in the root of > your Rails app.As Tony mentions rails is looking in the "public/stylesheets/" directory in the root of your Rails app... and note that rails creates this, so you shouldn''t need to. Also, it sounded like Michael might have created something in windows explorer and be wondering why it''s not showing up in the "Rails Navigator". If so, that''s because Eclipse (on which RadRails is based) does not monitor the underlying file system for changes. To get stuff you do outside of RadRails to show up, right click on your project in the navigator and choose "refresh" (or click on the project and hit "F5"). Hope I''m not treading the obvious... Wasn''t sure if there''s some confusion here or not... b PS: You can also get the "new" dialog by doing "ctrl-N"... you can see a list of keyboard shortcuts by doing "ctrl-shift-L" (though some aren''t going to work in a Ruby context).
From: "Ben Munat" <bent@munat.com>> Eclipse (on which RadRails is based) does not monitor the underlying file > system for changes.You can make Eclipse 3 (at least) monitor the file system via Window | Preferences | General | Workspace | Refresh automatically. ///ark
I''ve been using Eclipse for years now, and I can''t tell you how many times somebody points out a capability it has that I never knew about. Thanks for that tip. I''m so accustomed to doing a refresh I had no idea they found a way to make it automatic. Ken -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen@kousenit.com -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Mark Wilden Sent: Monday, February 13, 2006 1:33 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Re: CSS in Views From: "Ben Munat" <bent@munat.com>> Eclipse (on which RadRails is based) does not monitor the underlying file > system for changes.You can make Eclipse 3 (at least) monitor the file system via Window | Preferences | General | Workspace | Refresh automatically. ///ark _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Mark Wilden wrote:> From: "Ben Munat" <bent@munat.com> > >> Eclipse (on which RadRails is based) does not monitor the underlying >> file system for changes. > > > You can make Eclipse 3 (at least) monitor the file system via Window | > Preferences | General | Workspace | Refresh automatically. >HAH! Amazing... I guess there is always something new to learn about Eclipse! And what''s really funny is that I learned it on a ruby list! Of course, the question still remains: why doesn''t Eclipse just do that out of the box?!? Thanks very much for that. b
Michael Boutros wrote:> Andrew Otwell wrote: >>>How can I link to a CSS file in one of my view files? >> >> Typically you do this in your layouts: >> >> <%= stylesheet_link_tag "filename", :media => "all" %> >> >> More here: http://rails.rubyonrails.com/classes/ActionView/Helpers/ >> AssetTagHelper.html#M000397 > > I just tried this and in the source it is looking for > /stylesheets/filename. In RadRails you cannot create folders, so I > created the folder in explorer and moved the style.css file into that > folder, but it still is not reading it. Also, I have changed filename to > style.css. Thanks :)If your css file is living in myrailsapp/public/stylesheets and is called mystylesheet.css, you would use <%= stylesheet_link_tag "mystylesheet", :media => "all" %> The string you pass is the name of the file, minus the extension. Since your file is called style.css, you should use <%= stylesheet_link_tag "style" %>. Is this any clearer ? A. -- Posted via http://www.ruby-forum.com/.