CSS in Views

How can I link to a CSS file in one of my view files?

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: Peak Obsession
AssetTagHelper.html#M000397

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: Peak Obsession
AssetTagHelper.html#M000397

Thanks :slight_smile:

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: Peak Obsession
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 :slight_smile:

On 2/11/06, Michael B. [email protected] 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 :slight_smile:

It’s looking in the “public/stylesheets/” directory in the root of
your Rails app.

Tony

From: “Ben M.” [email protected]

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

Tony C. wrote:

folder, but it still is not reading it. Also, I have changed filename to
style.css. Thanks :slight_smile:

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).

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
[email protected]

Mark W. wrote:

From: “Ben M.” [email protected]

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 B. 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: Peak Obsession
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 :slight_smile:

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.