Sha256: 01e830e2f27907f6f5223aef1bd64b6c94241d6dddbd862d2070bd33e9c856d0
Contents?: true
Size: 1.28 KB
Versions: 62
Compression:
Stored size: 1.28 KB
Contents
module Workarea module Admin class BulkActionsController < Admin::ApplicationController def create klass = params[:type].constantize raise unless klass < BulkAction bulk_action = Mongoid::Factory.build(klass, bulk_action_params(klass)) if !bulk_action.valid? flash[:error] = bulk_action.errors.full_messages.to_sentence redirect_back(fallback_location: return_to || root_path) elsif !bulk_action.count.positive? flash[:error] = I18n.t('workarea.admin.bulk_actions.empty_selection') redirect_back(fallback_location: return_to || root_path) else bulk_action.save! redirect_to url_for([ :edit, bulk_action, { only_path: true, return_to: return_to } ]) end end def selected @search = BulkActionSelections.new(params[:id], params) @results = @search.results.map { |r| wrap_in_view_model(r) } end def destroy BulkAction.find(params[:id]).destroy redirect_to return_to || root_path end private def bulk_action_params(klass) base = params.select { |k, v| k.in?(klass.fields.keys) } base.merge(params[:bulk_action] || {}) end end end end
Version data entries
62 entries across 62 versions & 1 rubygems