Class: Ext::OgScaffold::OgScaffolder

Inherits:
Equipment::Resource::RestController
  • Object
show all
Defined in:
lib/ext/og_scaffold.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.modelObject

Returns the value of attribute model.



46
47
48
# File 'lib/ext/og_scaffold.rb', line 46

def model
  @model
end

Instance Method Details

#createObject

CRUD ###



50
51
52
53
54
55
56
# File 'lib/ext/og_scaffold.rb', line 50

def create
  m = model.new
  input.fill(m) # TODO : Make this work
  m.save
  flash.errors = m.errors
  redirect R(self, :show, m.oid)
end

#destroy(oid) ⇒ Object



72
73
74
75
# File 'lib/ext/og_scaffold.rb', line 72

def destroy(oid)
  flash.errors = model.delete(oid)        
  redirect R(self)
end

#edit(oid) ⇒ Object



84
85
86
87
88
# File 'lib/ext/og_scaffold.rb', line 84

def edit(oid)
  @model = model
  @model_instance = model[oid]
  render :edit
end

#indexObject

Views ###



79
80
81
82
# File 'lib/ext/og_scaffold.rb', line 79

def index
  @model = model
  render :index
end

#show(oid) ⇒ Object



58
59
60
61
62
# File 'lib/ext/og_scaffold.rb', line 58

def show(oid)
  @model = model
  @model_instance = model[oid]
  render :show
end

#update(oid) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/ext/og_scaffold.rb', line 64

def update(oid)
  m = model[oid]
  input.fill(m)
  m.save
  flash.errors = m.errors
  redirect R(self, :show, m.oid)
end