0
我有一個rails app(source)可以進行調度。我正嘗試在班次視圖和郵件消息之間重用template for shifts tables。如何在ActionMailer中重用Rails模板
我想刪除郵件消息的鏈接,但是對邏輯有困難。該HAML我目前是:
%table#shift-table
%tr
%th Start
⋮
%th Task
- if defined? params
%th.options
- @shifts.each do |shift|
%tr
%td= shift.start
⋮
%td= link_to_if(defined? params, shift.task.name, shift) if shift.task
- if defined? params
%td
= link_to 'Show', shift, class: [:btn, 'btn-default']
- if defined? can? and can? :update, shift
= link_to 'Edit', edit_shift_path(shift), class: [:btn, 'btn-default']
- if defined? can? and can? :destroy, shift
= link_to 'Delete', shift, :method => :delete, :data => { :confirm => 'Are you sure?' }, class: [:btn, 'btn-default']
的defined? params
在郵寄包裝true
,所以這是行不通的。當我嘗試params.nil?
或params[:controller]
,我得到:
undefined method `params' for #<ScheduleMailer:0xae5e520>
我要指出,我從rake task發送電子郵件。