abloom (owner)

Revisions

gist: 126017 Download_button fork
public
Public Clone URL: git://gist.github.com/126017.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class AbstractTopLevelController < ApplicationController
  class_inheritable_accessor :model
 
  def index
    model.classify.constantize.all
  end
end
 
class AbstractNestedController < ApplicationController
  class_inheritable_accessor :model
  class_inheritable_accessor :parent
 
  def index
    parent.classify.constantize.find(params["#{parent}_id".to_sym].send(model).all
  end
end
 
class FooController < AbstractTopLevelController
  self.model = "foo"
end
 
class NestedFooController < AbstractNestedController
  self.model = "foo"
  self.parent = "bar"
end