我可以 运行 rails 方法中的其他方法吗
Can I run other methods within a method on rails
我在模型中有一组方法。当前 after_create 回调中的所有方法 运行。像这样...
class DataAggregation
include Mongoid::Document
after_create :report_extras, :primary_income, :income_by_name, etc...
end
当我 运行 模型中的特定方法类似于这样时,我想使所有方法 运行...
def update_report
:report_extras, :primary_income, :income_by_name, etc...
end
我该怎么做,或者这是错误的,我应该在控制器中设置一些独特的调用。
你可以在你的方法中调用那些方法
after_create :update_report
# some code here
def update_report
report_extras
primary_income
income_by_name
end
我在模型中有一组方法。当前 after_create 回调中的所有方法 运行。像这样...
class DataAggregation
include Mongoid::Document
after_create :report_extras, :primary_income, :income_by_name, etc...
end
当我 运行 模型中的特定方法类似于这样时,我想使所有方法 运行...
def update_report
:report_extras, :primary_income, :income_by_name, etc...
end
我该怎么做,或者这是错误的,我应该在控制器中设置一些独特的调用。
你可以在你的方法中调用那些方法
after_create :update_report
# some code here
def update_report
report_extras
primary_income
income_by_name
end