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.
D3760253015655d7441a4206c762934d?d=identicon&s=25 Hugo Mag (migrate)
on 2007-01-19 10: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
3e6bbd5a01437feec48adf3838b15d91?d=identicon&s=25 askegg (Guest)
on 2007-01-19 11: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?
21053fc472ce35063e175e9cfbb78e6b?d=identicon&s=25 Gareth Adams (Guest)
on 2007-01-19 15: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.
70ca58d0e0e0eabbdb74d177417d09d7?d=identicon&s=25 augustlilleaas@gmail.com (Guest)
on 2007-01-19 16:31
(Received via mailing list)
You can set this in environment.rb.

ENV['RAILS_ASSET_ID'] = ""

This is outside of the Rails::Initializer stuff.
D3760253015655d7441a4206c762934d?d=identicon&s=25 Hugo Mag (migrate)
on 2007-01-19 21:21
augustlilleaas@gmail.com 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.