i need to use model callback when only selected action in controller
class TestController
def end_exam(); end
def resume_exam(); end
def continue_exam(); end
def review_exam(); end
end
class Test //Model
after_find :include_load_question_module // only for end_exam, resume, continue
end // not for review_exam
is there any possibilities
You can get detailed information in below link
http://www.gsubbarao.com/2012/11/ruby-on-rails-3x-skip-callback-and.html
这应该在测试模型(app / models / test.rb)中起作用:
skip_callback(:find, :after, :review_exam)
You can't do this magically: the model has no concept of who is calling it, so it can't change its behaviour based on the current controller action.
You'd be better off having a controller before_filter
that calls include_load_question_module
on the relevant instances.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.