diff --git a/app/controllers/admin/data_controller.rb b/app/controllers/admin/data_controller.rb index 7108bb4..e563f8e 100644 --- a/app/controllers/admin/data_controller.rb +++ b/app/controllers/admin/data_controller.rb @@ -26,7 +26,7 @@ def create if @item.save flash[:notice] = t(:saved, :scope => [:app, :admin_general]) end - respond_with(@datum, :location => admin_item_path(@item, :anchor => "datum_#{@datum.id}_edit")) + respond_with(@datum, location: params[:return_to] || admin_item_path(@item, :anchor => "datum_#{@datum.id}_edit")) end def edit @@ -40,7 +40,7 @@ def update if @datum.update_attributes(params[:datum]) format.html do flash[:notice] = t(:saved, :scope => [:app, :admin_items]) - redirect_to admin_item_path(@item, :anchor => "datum_#{@datum.id}") + redirect_to params[:return_to] || admin_item_path(@item, :anchor => "datum_#{@datum.id}") end format.json { render :json => @datum.to_json, :status => :ok } else diff --git a/app/views/admin/data/edit.html.erb b/app/views/admin/data/edit.html.erb index 1ff4e8f..3eadca9 100644 --- a/app/views/admin/data/edit.html.erb +++ b/app/views/admin/data/edit.html.erb @@ -6,6 +6,7 @@
<%= form_for [:admin, @item, @datum], as: :datum, url: admin_item_datum_path(@datum, item_id: @item) do |f| %> + <%= hidden_field_tag :return_to, admin_item_data_path(@item) %> <%= render 'admin/shared/error_messages', :object => f.object %> <%= render 'form', :f => f %> <% begin %> diff --git a/app/views/admin/data/new.html.erb b/app/views/admin/data/new.html.erb index 942ba77..467cc2c 100644 --- a/app/views/admin/data/new.html.erb +++ b/app/views/admin/data/new.html.erb @@ -6,6 +6,7 @@
<%= form_for [:admin, @item, @datum], as: :datum, url: admin_item_data_path(@item) do |f| %> + <%= hidden_field_tag :return_to, admin_item_data_path(@item) %> <%= render 'admin/shared/error_messages', :object => f.object %> <%= render 'form', :f => f %> <% begin %>