Module: Gridy::Controller::Actions

Extended by:
ActiveSupport::Concern
Defined in:
lib/gridy/controller/actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
# File 'lib/gridy/controller/actions.rb', line 29

def create
  self.resource_instance = resource_class.new(resource_params)

  if resource_instance.save
    redirect_to resource_instance, notice: "#{resource_name.titleize} was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



47
48
49
50
# File 'lib/gridy/controller/actions.rb', line 47

def destroy
  resource_instance.destroy!
  redirect_to resource_index_url, notice: "#{resource_name.titleize} was successfully destroyed."
end

#editObject



26
27
# File 'lib/gridy/controller/actions.rb', line 26

def edit
end

#indexObject



14
15
16
17
# File 'lib/gridy/controller/actions.rb', line 14

def index
  gridy_collection(collection, params)
  render "index"
end

#newObject



22
23
24
# File 'lib/gridy/controller/actions.rb', line 22

def new
  self.resource_instance = resource_class.new
end

#showObject



19
20
# File 'lib/gridy/controller/actions.rb', line 19

def show
end

#updateObject



39
40
41
42
43
44
45
# File 'lib/gridy/controller/actions.rb', line 39

def update
  if resource_instance.update(resource_params)
    redirect_to resource_instance, notice: "#{resource_name.titleize} was successfully updated."
  else
    render :edit, status: :unprocessable_entity
  end
end