开发者

How to write rails like before_filter and after_filter for a stand alone ruby program

开发者 https://www.devze.com 2023-02-16 21:34 出处:网络
I have been given an exercise to write code for rails like before_filter an开发者_如何学编程d after_filter for a stand alone Ruby program. Not surprisingly I don\'t know how to write.The simplest way

I have been given an exercise to write code for rails like before_filter an开发者_如何学编程d after_filter for a stand alone Ruby program. Not surprisingly I don't know how to write.


The simplest way to do this would be to use ActiveModel::Callbacks (you can require ActiveModel by itself outside of Rails), then you get all the niceness without having to mess about implementing it yourself.


I guess you just started learning rails. Go through the filters section of this link

http://guides.rubyonrails.org/action_controller_overview.html

It will be definitely good for your learning curve.


This question, I think, has the answer to your question:

How to implement a "callback" in Ruby?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号