lib/puffer/base.rb in puffer-0.0.19 vs lib/puffer/base.rb in puffer-0.0.20

- old
+ new

@@ -1,11 +1,10 @@ module Puffer class Base < ApplicationController unloadable pufferize! - view_paths_fallbacks :puffer define_fields :index, :show, :form, :create, :update respond_to :html, :js def index @@ -25,22 +24,28 @@ end def create @record = resource.new_member @record.save - respond_with @record, :location => resource.collection_path + respond_with @record, :location => puffer_saving_location end def update @record = resource.member @record.update_attributes resource.attributes - respond_with @record, :location => resource.collection_path + respond_with @record, :location => puffer_saving_location end def destroy @record = resource.member @record.destroy redirect_to (request.referrer || resource.collection_path) + end + + private + + def puffer_saving_location + params[:commit] == t('puffer.save') ? resource.edit_path(record) : resource.collection_path end end end