Module: Rango::GV::Scaffolding

Extended by:
RenderMixin
Defined in:
lib/rango/gv/scaffolding.rb

Class Method Summary collapse

Methods included from RenderMixin

render

Class Method Details

.create(klass, show_url) ⇒ Object



35
36
37
38
39
40
# File 'lib/rango/gv/scaffolding.rb', line 35

def self.create(klass, show_url)
  Rango::Mini.app do |request, response|
    klass.create!(params[:post])
    response.redirect show_url
  end
end

.destroy(klass, list_url) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/rango/gv/scaffolding.rb', line 42

def self.destroy(klass, list_url)
  Rango::Mini.app do |request, response|
    object = klass.get(params[:id])
    object.destroy
    response.redirect list_url
  end
end

.list(klass) ⇒ Object



15
16
17
18
19
20
# File 'lib/rango/gv/scaffolding.rb', line 15

def self.list(klass)
  Rango::Mini.app do |request, response|
    objects = klass.all
    render "scaffolding/list.html", objects: objects
  end
end

.new(klass) ⇒ Object



29
30
31
32
33
# File 'lib/rango/gv/scaffolding.rb', line 29

def self.new(klass)
  Rango::Mini.app do |request, response|
    render "scaffolding/new.html", object: klass.new
  end
end

.show(klass) ⇒ Object



22
23
24
25
26
27
# File 'lib/rango/gv/scaffolding.rb', line 22

def self.show(klass)
  Rango::Mini.app do |request, response|
    object = klass.get(params[:id])
    render "scaffolding/show.html", object: object
  end
end