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. 4
      lib/widget.rb

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

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

Loading…
Cancel
Save