lib/right_rails/controller_extensions.rb in right-rails-0.6.0 vs lib/right_rails/controller_extensions.rb in right-rails-1.0.0
- old
+ new
@@ -28,21 +28,28 @@
# page[:zings].last.hide('slide')
# end
# end
#
def rjs(options={}, &block)
- @template.send(:_evaluate_assigns_and_ivars)
+ template = if @template
+ @template.send(:_evaluate_assigns_and_ivars)
+ @template
+ else
+ view_context
+ end
- wrapper = RenderWrapper.new(@template, options)
+ wrapper = RenderWrapper.new(template, options)
if block_given?
wrapper.render_block(&block)
else
wrapper
end
end
+private
+
#
# This class wraps the standard JavaScript responses in the controller
#
# It delegates all the script generating calls to the JavaScriptGenerator
# instance, then grabs thre reults and creates a suitable hash of options
@@ -63,20 +70,18 @@
def method_missing(name, *args)
@generator.send(name, *args)
render
end
- protected
-
#
# Compiles the options for the controller#render method
#
def render
result = {:text => @generator.to_s, :content_type => Mime::JS}
# iframed uploads context overloading
if @template.request.content_type == 'multipart/form-data'
- result.merge! :content_type => Mime::HTML, :layout => 'iframed'
+ result.merge! :content_type => Mime::HTML, :layout => 'iframed.html.erb'
end
result.merge! @options
end
end
\ No newline at end of file