How to use my view helpers in my ActionMailer views?
2010-12-15 19:56
956 查看
How to use my view helpers in my ActionMailer views?
up vote3down votefavorite | I want to use the methods I defined in app/helpers/annotations_helper.rbin my ReportMailer views ( app/views/report_mailer/usage_report.text.html.erb). How do I do this? Based on this guide it seems like the add_template_helper(helper_module)method might do what I want, but I can't figure out how to use it. (BTW, is there a reason you get access to a different set of helpers in mailer views? This is pretty annoying.) ruby-on-rails
|
2 Answers
activenewestvotesup vote6down voteaccepted | In the model class that you are using to manage your emails:class ReportMailer < ActionMailer::Base add_template_helper(AnnotationsHelper) ... end
| ||
|
up vote0down vote | This might give you some direction, I have a method "check_options" defined in "app/helpers/app_helper.rb" In my controller that renders the view "app/controllers/app_controller.rb" I have the following line helper: all # include all the helpers all the timeand then finally in my view I just call the "check_options" like <% if check_options ...From the documentation link that you posted looks like you might need helper(*args, &block) Declare a helper: "helper :foo" requires ‘foo_helper’ and includes FooHelper in the template class.Give this link a try as well http://caboo.se/doc/classes/ActionController/Helpers/ClassMethods.html there are some examples that might help A small excerpt from the page "By default, the controller will include a helper whose name matches that of the controller, e.g., MyController will automatically include MyHelper." Cheers
| ||
相关文章推荐
- How can I force WebLogic to use third party jars that are included in my Ear?
- Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- 使用eclipse编程出现Use View.isInEditMode() in your custom views to skip code when shown in Eclipse解决方法
- XAF How to enable LayoutView mode in the GridControl in List Views
- Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
- Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
- How to use isInEditMode() to see layout with custom View in the editor
- Learn how to Use UIPageViewController in iOS
- How to use JSon data in mvc action and post form data use JQuery ajax
- Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
- Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- Topic : How to use TabBar in viewbase application
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project
- Applications Programming in Smalltalk-80(TM):How to use Model-View-Controller (MVC)
- 【Android笔记】引用第三方自定义控件出错:Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- How to use OpenChatter in my addon