Return html in response instead of redirect url.

pull/6827/head
Christian Rijke 12 years ago
parent 1558fc5580
commit 8923bd5529
  1. 14
      lib/report/controller.rb
  2. 8
      lib/widget.rb

@ -36,19 +36,13 @@ module Report::Controller
end
def table_without_progress_info
stream do
render_widget Widget::Table, @query
end
render :text => render_widget(Widget::Table, @query), :layout => !request.xhr?
end
def table_with_progress_info
render :text => render_widget(Widget::Table::Progressbar, @query), :layout => !request.xhr?
end
def stream(&block)
self.response_body = block
end
##
# Create a new saved query. Returns the redirect url to an XHR or redirects directly
def create
@ -56,9 +50,9 @@ module Report::Controller
@query.public! if make_query_public?
@query.send("#{user_key}=", current_user.id)
@query.save!
if request.xhr? # Update via AJAX - return url for redirect
render :text => url_for(:action => "show", :id => @query.id)
else # Redirect to the new record
if request.xhr?
table
else
redirect_to :action => "show", :id => @query.id
end
end

@ -34,12 +34,8 @@ class Widget < ActionView::Base
module RenderWidgetInstanceMethods
def render_widget(widget, subject, options = {}, &block)
i = widget.new(subject)
if Rails.version.start_with? "3"
i.config = config
i._routes = _routes
else
i.output_buffer = ""
end
i.config = config
i._routes = _routes
i._content_for = @_content_for
i.controller = respond_to?(:controller) ? controller : self
i.render_with_options(options, &block)

Loading…
Cancel
Save