Module: Dry::Controller

Extended by:
ActiveSupport::Concern
Includes:
RoutingHelpers
Defined in:
lib/dry/controller.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from RoutingHelpers

#collection_path, #edit_path, #form_arguments, #new_path, #record_path, #relation_path

Instance Method Details

#createObject



59
60
61
62
63
64
65
66
67
# File 'lib/dry/controller.rb', line 59

def create
  @record = resource_scope.new record_params
  if @record.save
    redirect_to collection_path(@resource),
      notice: "#{model_name.singular.capitalize} was successfully created."
  else
    render :new
  end
end

#destroyObject



78
79
80
81
82
# File 'lib/dry/controller.rb', line 78

def destroy
  @record.destroy
  redirect_to collection_path(@resource),
    notice: "#{model_name.singular.capitalize} was successfully destroyed."
end

#editObject



56
57
# File 'lib/dry/controller.rb', line 56

def edit
end

#indexObject



46
47
# File 'lib/dry/controller.rb', line 46

def index
end

#newObject



52
53
54
# File 'lib/dry/controller.rb', line 52

def new
  @record = resource_scope.new
end

#showObject



49
50
# File 'lib/dry/controller.rb', line 49

def show
end

#updateObject



69
70
71
72
73
74
75
76
# File 'lib/dry/controller.rb', line 69

def update
  if @record.update record_params
    redirect_to collection_path(@resource),
      notice: "#{model_name.singular.capitalize} was successfully updated."
  else
    render :edit
  end
end