requirejs-rails
requirejs-rails copied to clipboard
undefined method `request_uri' for #<URI::Generic:0x000000081c95c8>
Getting this error when my baseUrl starts with "//" instead of "http://" or "https://".
Note that there's no reason to set baseUrl
unless you're using it for CDN hosting. That said, what do you hope to accomplish with a null URL protocol?
Next, please give a complete example of your baseUrl. It's fine to change names, etc., but you haven't given me enough information to determine if there's a real issue here, e.g. in what URI.parse returning vs. what the gem's code expects.
Last but not least, please provide the stack backtrace with issue reports.
In https://github.com/jwhitley/requirejs-rails/blob/master/app/helpers/requirejs_helper.rb#L100
1.9.3p125 :008 > URI.parse('http://cdn.awsstuff.com').request_uri => "/" 1.9.3p125 :009 > URI.parse('https://cdn.awsstuff.com').request_uri => "/" 1.9.3p125 :010 > URI.parse('//cdn.awsstuff.com').request_uri NoMethodError: undefined method `request_uri' for #<URI::Generic:0x000001010484c0 URL://cdn.awsstuff.com> from (irb):10
I'd have to do more work to get the actual stacktraces and urls.
The use case is exactly that of serving assets from a CDN (cloudfront).
Confirmed, thanks.
Unfortunately, I am having the same error which is preventing me to release in staging/production:
Exception.message: undefined method `request_uri' for #<URI::Generic:0x007ffcb6257528>
Rails env: staging
Completed 500 Internal Server Error in 2459ms
ActionView::Template::Error (undefined method request_uri' for #<URI::Generic:0x007ffcb6257528>): 5: = stylesheet_link_tag "application", :media => "all" 6: %script{:src => 'http://connect.facebook.net/en_US/all.js'} 7: %script{:src => 'http://platform.twitter.com/widgets.js'} 8: = requirejs_include_tag "application" 9: 10: /[if lt IE 9] 11: %script{:src => "http://html5shim.googlecode.com/svn/trunk/html5.js", :type => "text/javascript"} app/views/layouts/application.html.haml:8:in
_app_views_layouts_application_html_haml__2820337099112226929_70361663209760'
Rendered /Users/riteshn/.rvm/gems/ruby-1.9.3-p374@beamtous/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.4ms) Rendered /Users/riteshn/.rvm/gems/ruby-1.9.3-p374@beamtous/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.3ms) Rendered /Users/riteshn/.rvm/gems/ruby-1.9.3-p374@beamtous/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (27.4ms) ^[^[
...
In my config/environments/staging.rb:
config.requirejs.run_config['baseUrl'] = 'http://beamtous-staging-assets.s3.amazonaws.com/assets
I'm running into this, too (setting config.requirejs.run_config['baseUrl'] in config/environments/staging.rb). Initially using //, now using https://, running into the error both ways: "undefined method `request_uri' for #URI::Generic:0x007f0b2a04e778".
I think request.request_uri
has been deprecated.
Now we can use:
request.url
I'm encountering this issue as well. Any fix for it so i can dynamically choose between http or https? I am trying to hook my cloudfront CDN
All, it looks like enough people have been asking for additional degrees of CDN URL customization. I'll try to look into this over the weekend and ping folks asking for clarifications and examples.
Isn't it a Ruby stdlib issue? Is there any reason why URI::Generic
does not have #request_uri
?
irb(main):007:0> URI::Generic.class_eval do
irb(main):008:1* def request_uri
irb(main):009:2> return nil unless @path
irb(main):010:2> if @path.start_with?(?/.freeze)
irb(main):011:3> @query ? "#@path?#@query" : @path.dup
irb(main):012:3> else
irb(main):013:3* @query ? "/#@path?#@query" : "/#@path"
irb(main):014:3> end
irb(main):015:2> end
irb(main):016:1> end
=> :request_uri
irb(main):017:0> URI::HTTP.superclass
=> URI::Generic
irb(main):018:0> URI.parse('//cdn.awsstuff.com').request_uri
=> "/"