On Dec 11, 2008, at 4:40 AM, Valentino Lun wrote:
> I think I identified the problem now
Have you also been able to fix it?
> In asset_tag_help.rb, the problem might cause from *****(see below
> code). I am using Rails 2.1.2, I will try the latest version to see
> the
> problem has been fixed. Thanks all
>
> def image_path(source)
> compute_public_path(source, 'images')
> end
>
>
> def compute_public_path(source, dir, ext = nil, include_host =
> true)
> has_request = @controller.respond_to?(:request)
>
> cache_key =
> if has_request
> [ @controller.request.protocol,
> ActionController::Base.asset_host.to_s,
> @controller.request.relative_url_root,
> dir, source, ext, include_host ].join
> else
> [ ActionController::Base.asset_host.to_s,
> dir, source, ext, include_host ].join
> end
>
> ActionView::Base.computed_public_paths[cache_key] ||=
> begin
> ***** source += ".#{ext}" if ext &&
> File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir,
> "#{source}.#{ext}"))
The thing is, source += ".#{ext}" will only be executed if ext is
not nil. In this case, I think ext is nil, so this should be causing
the problem.
But if something is really mysterious (and in Rails it often is),
then I just add lots of debug statements and see what really happens.
puts all the names of methods that are called, and all relevant
variables (or just use the debugger, of course!), and see where the
dot is added. You may have found a bug in Rails.
> if source =~ %r{^[-a-z]+://}
> source
> else
> source = "/#{dir}/#{source}" unless source[0] == ?/
> if has_request
> unless source =~
> [EMAIL PROTECTED]/}
> source =
> "[EMAIL PROTECTED]"
> end
> end
>
> rewrite_asset_path(source)
> end
> end
All this code is also capable of changing source. I've got no idea
what it does, but if you just puts the value of source after each
one, you'll see where the dot gets added.
That's the only advice I can give you. Other than that, I'm
stumped.
mcv.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---