[英]DSL configuration within activerecord model in Rails 3
I want to build reports for some database data. 我想为一些数据库数据构建报告。 I store report's settings in database through activerecord models, but I don't want that, I want to write something like 我通过activerecord模型将报表的设置存储在数据库中,但我不想这样,我想写类似的东西
class Department < ActiveRecord::Base
...
report do
name "Total Sales by Departments"
method :name
report_field do
name "Total Sales"
action :sum
relation "Sales"
method :spent
end
report_field do
name "Average Sales"
action :avg
relation "Sales"
method :spent
end
end
end
Can someone please tell me how this is possible to do and what should I read, maybe some examples of other things that are similar to my problem? 有人可以告诉我这是怎么做的,我应该阅读什么,也许有一些与我的问题类似的其他事情的例子?
我首先阅读有关类宏的内容 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.