在插件中添加 Controller
galeki
posted @ 2008年4月16日 00:26
in RoR
with tags
controller
, 3276 阅读
原来以为,通过插件添加新的 Controller 很难,其实非常简单,只要建个 xxx.controller.rb 文件,然后在里面按照普通的方式定义这个 Controller:
-
class XxxController < ActionController::Base
-
-
....
-
-
end
然后在插件的 init.rb 里 require 这个文件就可以了……
再按照自己喜欢的格式添加个 route:
-
class ActionController::Routing::RouteSet
-
unless (instance_methods.include?('draw_with_xxx'))
-
class_eval <<-"end_eval", __FILE__, __LINE__
-
alias draw_without_xxx draw
-
def draw_with_xxx
-
draw_without_xxx do |map|
-
map.connect '/xxx/do_xxx', :controller => 'xxx', :action => 'do_xxx'
-
yield map
-
end
-
end
-
alias draw draw_with_xxx
-
end_eval
-
end
-
end
搞定收工~
2022年5月17日 17:14
Maharashtra State Board of Secondary & Higher Secondary Education (MSBSHSE) Responsible For Conducting Std 12th Class Final Examinations will be held from Tentatively held from March 4th, to End Exam March 22. Maha Board has Released the 12th Exam Date Sheet early to help Schools and Teachers make All necessary Arrangements in Advance. , Students Download Maha Board 12th Model Paper 2022 at Official Website, <a href="https://boardmodelpaper.com/maharashtra-question-paper-for-hsc-maha-board-12th-model-paper/">MSBSHSE HSC Model Paper</a> We are Providing here the Detailed Schedule for Std 12th Class Final Examination 2022. Students can Check and Download the Routine to know Examination Dates and make their Preparation strategy in accordance with the same.
2023年4月14日 01:41
I encourage you to read this text it is fun described ... Termite Treatment Orlando
2023年4月14日 01:43
wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple , Pest Control Lakeland
2023年6月18日 17:27
On that website page, you'll see your description, why not read through this. unique tiles
2023年6月21日 01:08
The most interesting text on this interesting topic that can be found on the net ... grand dunman
2023年6月23日 18:22
Profit primarily prime quality items -- you can understand them all within: TATTOOS
2023年6月26日 17:42
Find the best essays on is my friend's profile page. جهاز العاب الطيبين