app/controllers/prosperity/dashboards_controller.rb in prosperity-0.0.5 vs app/controllers/prosperity/dashboards_controller.rb in prosperity-0.0.6

- old
+ new

@@ -9,25 +9,36 @@ def new @dashboard = Dashboard.new end def show - @dashboard = Dashboard.find(params[:id]) + dashboard end def edit - @dashboard = Dashboard.find(params[:id]) + dashboard end def create @dashboard = Dashboard.new @dashboard.title = params.fetch(:dashboard, {})[:title] @dashboard.default = false if @dashboard.save - redirect_to action: :index + redirect_to edit_dashboard_path(@dashboard) else flash[:error] = @dashboard.errors.full_messages.to_sentence render action: :new end + end + + def destroy + dashboard.destroy + redirect_to action: 'index' + end + + private + + def dashboard + @dashboard ||= Dashboard.find(params[:id]) end end end