Forum: Ruby on Rails CSS in Views

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2d66c63b4d8193d0279bd18200e109d3?d=identicon&s=25 Michael Boutros (Guest)
on 2006-02-12 01:18
How can I link to a CSS file in one of my view files?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Andrew Otwell (Guest)
on 2006-02-12 01:21
(Received via mailing list)
>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
2d66c63b4d8193d0279bd18200e109d3?d=identicon&s=25 Michael Boutros (Guest)
on 2006-02-12 02:27
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

Thanks :)
2d66c63b4d8193d0279bd18200e109d3?d=identicon&s=25 Michael Boutros (michaelboutros)
on 2006-02-12 03:24
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 :)
3c61994644f5d19eb104fb36de8f46da?d=identicon&s=25 Tony Collen (Guest)
on 2006-02-12 03:28
(Received via mailing list)
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.


Tony
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-12 07:17
(Received via mailing list)
Tony Collen wrote:
>>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).
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2006-02-13 19:33
(Received via mailing list)
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
432fcf0d43d64c1189d9672716ac679d?d=identicon&s=25 Ken Kousen (kousen)
on 2006-02-13 21:05
(Received via mailing list)
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
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-02-14 02:08
(Received via mailing list)
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
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-02-14 14:47
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.
This topic is locked and can not be replied to.