Skip to content

Commit

Permalink
Redirect back to data view after create, edit, delete
Browse files Browse the repository at this point in the history
Closes #153
  • Loading branch information
Alexis Fellenius committed Oct 9, 2013
1 parent da3ee4c commit 1895730
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/data_controller.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/data/edit.html.erb
Expand Up @@ -6,6 +6,7 @@
</div>
<div id="content">
<%= 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 %>
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/data/new.html.erb
Expand Up @@ -6,6 +6,7 @@
</div>
<div id="content">
<%= 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 %>
Expand Down

0 comments on commit 1895730

Please sign in to comment.