lib/restfulx/rails/swf_helper.rb in dima-restfulx-1.2.2 vs lib/restfulx/rails/swf_helper.rb in dima-restfulx-1.2.3
- old
+ new
@@ -1,20 +1,19 @@
# Adds a little helper to make it easier empbedding SWFs in ERB templates.
module SWFHelper
-
# Creates a swfObject Javascript call. You must include swfobject.js to use this.
# See http://code.google.com/p/swfobject/wiki/documentation for full details and documentation
# of the swfobject js library.
def swfobject(swf_url, params = {})
params.reverse_merge!({:width => '100%',
:height => '100%',
:id => 'flashContent',
:version => '9.0.0',
:express_install_swf => '/expressInstall.swf',
:flash_vars => nil,
- :params => nil,
- :attributes => nil,
+ :params => { },
+ :attributes => { },
:create_div => false,
:include_authenticity_token => true,
:include_session_token => true
})
arg_order = [:id, :width, :height, :version, :express_install_swf]
@@ -27,20 +26,21 @@
# <script>
# ... other code that defines flashVars and sets some of its parameters
# flashVars['authenticity_token'] = <%= form_authenticity_token -%>
# flashVars['session_token'] = <%= session.session_id -%>
# </script>
- # If you include an authenticity_token parameter in flashVars,
- # then the Flex app will add it to Rx.defaultMetadata, so that it will be sent
- # back up to your Rails app with every request.
params[:flash_vars] ||= {}
if params[:flash_vars].is_a?(Hash)
if params[:include_authenticity_token] && ActionController::Base.allow_forgery_protection
params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
end
if params[:include_session_token]
- params[:flash_vars].reverse_merge!(:session_token => session.session_id)
+ if RAILS_GEM_VERSION =~ /^2.3/
+ params[:flash_vars].reverse_merge!(:session_token => request.session_options[:id])
+ else
+ params[:flash_vars].reverse_merge!(:session_token => session.session_id)
+ end
end
end
js_params += [params[:flash_vars], params[:params], params[:attributes]].collect do |hash_or_string|
if hash_or_string.is_a?(Hash)
@@ -54,7 +54,6 @@
"swfobject.embedSWF(#{js_params.join(',')})"
end
swf_tag += content_tag(:div, nil, :id => params[:id]) if params[:create_div]
swf_tag
end
-
end