Commit 6446715b by liyijie

Add base controller for block process

parent d43ed82b
...@@ -2,15 +2,30 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -2,15 +2,30 @@ class SimpleController::BaseController < ::InheritedResources::Base
respond_to :json respond_to :json
def index def index
index!( { template: "#{self.class.view_path}/index" } ) index!
end end
def show def show
show!( { template: "#{self.class.view_path}/show" } ) show!
end end
def create def create
create!( { template: "#{self.class.view_path}/show", status: 201 } ) create!
end
def index!(options={}, &block)
options = { template: "#{self.class.view_path}/index" }.merge options
super(options, &block)
end
def show!(options={}, &block)
options = { template: "#{self.class.view_path}/show" }.merge options
super(options, &block)
end
def create!(options={}, &block)
options = { template: "#{self.class.view_path}/show", status: 201 }.merge options
super(options, &block)
end end
protected protected
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment