Erwin
2011-Sep-28 13:23 UTC
Rails 3.1 How to use CDN-hosted jQuery libraries vs assets pipeline
I am testing some code to be used out of an Rails app, using JQuery and jQuery-ui as the final html code will have links to CDN-hosted libraries, with links to src : "http:////ajax.googleapis.com/ajax/libs/jquery/1.6.4/ jquery.min.js" and src: "http//ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery- ui.min.js" how can I use these standards with Rails 3.1 assets ? should I modify the application.js and get rid of //= require query I''m a little bit lost ... -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Martin Wawrusch
2011-Sep-28 13:32 UTC
Re: Rails 3.1 How to use CDN-hosted jQuery libraries vs assets pipeline
See here:
application.js
// This is a manifest file that''ll be compiled into including all the
files
listed below.
// Add new JavaScript/Coffee code in separate files in this directory and
they''ll automatically
// be included in the compiled file accessible from
http://example.com/assets/application.js
// It''s not advisable to add code directly here, but if you do,
it''ll appear
at the bottom of the
// the compiled file.
//
//= require jquery_ujs
// your stuff below
jquery.js
// This is a manifest file that''ll be compiled into including all the
files
listed below.
// Add new JavaScript/Coffee code in separate files in this directory and
they''ll automatically
// be included in the compiled file accessible from
http://example.com/assets/application.js
// It''s not advisable to add code directly here, but if you do,
it''ll appear
at the bottom of the
// the compiled file.
//
// This is the fallback file that is used when all other things fail.
//= require jquery
//= require jquery-ui
head.js
// This is a manifest file that''ll be compiled into including all the
files
listed below.
// Add new JavaScript/Coffee code in separate files in this directory and
they''ll automatically
// be included in the compiled file accessible from
http://example.com/assets/application.js
// It''s not advisable to add code directly here, but if you do,
it''ll appear
at the bottom of the
// the compiled file.
//
//
//= require external_head/modernizr-2.0
your footer template (I left a lot of other stuff in there, might be
helpful)
%script{:type=>''text/javascript''}
="window.loginStatus = {loggedIn: #{current_user ? ''true''
: ''false''} ,
service_facebook : #{current_user && current_user.service_facebook? ?
''true''
: ''false''} , service_twitter : #{current_user &&
current_user.service_twitter? ? ''true'' :
''false''} };"
= javascript_include_tag "http://connect.facebook.net/en_US/all.js"
= javascript_include_tag "
http://ajax.googleapis.com/ajax/libs/jquery/#{APP_JQUERY_VERSION}/jquery.min.js
"
= javascript_include_tag "
http://ajax.googleapis.com/ajax/libs/jqueryui/#{APP_JQUERYUI_VERSION}/jquery-ui.min.js
"
-jquery_path = asset_path(''jquery.js'')
:javascript
!window.jQuery && document.write(unescape(''%3Cscript
src="#{jquery_path}"%3E%3C/script%3E''))
= javascript_include_tag "
http://maps.google.com/maps/api/js?sensor=false&key=#{APP_GOOGLE_MAPS_KEY}"
= yield :templates
= javascript_include_tag "application", :debug =>
Rails.env.development?
/[if lt IE 8 ]
= javascript_include_tag ''
http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js''
:javascript
try { CFInstall.check({mode: "overlay",destination:
"http://freshfugu.com"});
} catch(ex) {}
-# Append your own using content_for :javascripts
= yield :javascripts
-# yui profiler and profileviewer
-#- if Rails.env == ''development''
-# = javascript_include_tag ''profiling/yahoo-profiling.min'',
''profiling/config''
On Wed, Sep 28, 2011 at 6:23 AM, Erwin
<yves_dufour-ee4meeAH724@public.gmane.org> wrote:
> I am testing some code to be used out of an Rails app, using JQuery
> and jQuery-ui
> as the final html code will have links to CDN-hosted libraries, with
> links to
> src : "http:////ajax.googleapis.com/ajax/libs/jquery/1.6.4/
> jquery.min.js" and
> src: "http//ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-
> ui.min.js"
>
> how can I use these standards with Rails 3.1 assets ?
> should I modify the application.js and get rid of //= require query
> I''m a little bit lost ...
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.