我的問題是,我沒有想法創建一個用戶列表的電子郵件,並在同一個列表中有一個複選框爲每個用戶,然後在最後有一個按鈕'發送' 和發送的所有電子郵件的用戶的檢查,我解決了temporaly有: 1)名單(索引視圖)複選框發送電子郵件紅寶石軌道上
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Correo</th>
<th>Send Email</th>
<th></th>
<th></th>
<th></th>
</tr>
<% var1 = []; i = 0 %>
<% @users.each do |user| %>
<tr id=<%= if user.value == 'No dispatched'
'c'
elsif user.value == 'Dispatched'
'a'
else
'b'
end%> >
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.value %></td>
<td><% var1[i] = user.name; i=i+1 %>
<%= button_to 'Activate/Desactivate', edit_send_path(user.id), :method => :get %> </td>
</td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New User', new_user_path %>
<%= button_to 'Send', {:controller => :Send, :action => :send}, :method => :get, :value => 2 %>
2)發送控制器
class SendController < ApplicationController
def send
@users = User.all
@users.each do |user|
if user.value == 'In Process'
UserMailer.registration_confirmation(user).deliver
user.value = 'Dispatched'
user.save
end
end
redirect_to :controller => :users, :protocol => 'http'
end
def edit
user = User.find(params[:id])
if user.value == 'In process'
user.value = 'No dispatched'
user.save
elsif user.value == 'No dispatched'
user.value = 'In process'
user.save
end
redirect_to :controller => :users, :protocol => 'http'
end
end
我使用標記「值」以檢查電子郵件是否被髮送
謝謝你真的幫我!你的解釋非常明確,特別,謝謝 – gaf 2012-08-16 17:27:43