app/controllers/effective/regions_controller.rb in effective_regions-1.4.1 vs app/controllers/effective/regions_controller.rb in effective_regions-1.4.2

- old
+ new

@@ -16,11 +16,12 @@ # TODO: turn this into a cookie or something better. redirect_to request.url.gsub('/edit', '') + '?edit=true' end def update - javascript_should_refresh_page = '' + refresh_page = false + response = {} Effective::Region.transaction do (request.fullpath.slice!(0..4) rescue nil) if request.fullpath.to_s.starts_with?('/edit') # This is so the before_save_method can reference the real current page region_params.each do |key, vals| # article_section_2_title => {:content => '<p></p>'} @@ -46,22 +47,22 @@ region.snippets = HashWithIndifferentAccess.new() (vals[:snippets] || []).each { |snippet, vals| region.snippets[snippet] = vals } # Last chance for a developer to make some changes here - if (run_before_save_method(region, regionable) rescue nil) == :refresh - javascript_should_refresh_page = 'refresh' - end + refresh_page = true if (run_before_save_method(region, regionable) rescue nil) == :refresh to_save.save! end # Hand off the appropriate params to EffectivePages gem - if defined?(EffectivePages) + if defined?(EffectivePages) && params[:effective_menus].present? Effective::Menu.update_from_effective_regions!(params[:effective_menus]) end - render :text => javascript_should_refresh_page, :status => 200 + response[:refresh] = true if refresh_page + + render :json => response.to_json(), :status => 200 return end render :text => 'error', :status => :unprocessable_entity end