Forum: Ruby on Rails Problem with link tags

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.
Hugo M. (Guest)
on 2007-01-19 11:27
Hell all,
I have a layout were I add my stylesheets and javascript in the
following manner:

<%= stylesheet_link_tag "/form" %>
<%= stylesheet_link_tag "/text" %>
<%= javascript_include_tag  :defaults %>

But what happens is that in the actual web page the source is the
following:

<link href="/form.css?1168168516" media="screen" rel="Stylesheet"
type="text/css" />
<link href="/text.css?1167565056" media="screen" rel="Stylesheet"
type="text/css" />
<script src="/javascripts/prototype.js?1167563816"
type="text/javascript"></script>
<script src="/javascripts/effects.js?1167563816"
type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1167563816"
type="text/javascript"></script>
<script src="/javascripts/controls.js?1167563816"
type="text/javascript"></script>

So Rails is adding some numbers to the links. This breaks my javascripts
and stylesheets. Can anyone help me?

Thanks.
Bye,
Migrate
askegg (Guest)
on 2007-01-19 12:35
Hu Ma wrote:
>
> So Rails is adding some numbers to the links. This breaks my javascripts
> and stylesheets. Can anyone help me?
>
> Thanks.
> Bye,
> Migrate

I believe rails does that to bypass any caching that can break scripts.

It should not break them though.  Are you sure your scripts are in the
correct directory?
Gareth A. (Guest)
on 2007-01-19 16:29
(Received via mailing list)
askegg <rails-mailing-list@...> writes:

>
> I believe rails does that to bypass any caching that can break scripts.
>
> It should not break them though.  Are you sure your scripts are in the
> correct directory?
>

I'll second this. It shouldn't break your files at all.

The number is just a timestamp for the last file modification time. It's
there
to ensure that any UA which is sloppy about caching will always get new
versions
of the files when they're updated.

I think the problem is the / in front of your CSS names. This would be
look for
the CSS files inside your /public directory, whereas they would normally
be
stored in /public/stylesheets.

Using <% stylesheet_link_tag "form" %> will create a link to
/stylesheets/form.css which is probably what you're looking for.
(Guest)
on 2007-01-19 17:31
(Received via mailing list)
You can set this in environment.rb.

ENV['RAILS_ASSET_ID'] = ""

This is outside of the Rails::Initializer stuff.
Hugo M. (Guest)
on 2007-01-19 22:21
removed_email_address@domain.invalid wrote:
> You can set this in environment.rb.
>
> ENV['RAILS_ASSET_ID'] = ""
>
> This is outside of the Rails::Initializer stuff.

Thanks for all your help.
There's no problem with the link tags. I found out that it was my fault.
I had them in the wrong place.

Bye,
Migrate
This topic is locked and can not be replied to.