Skip to content

Commit

Permalink
refine email template
Browse files Browse the repository at this point in the history
  • Loading branch information
xdite committed Jul 17, 2014
1 parent b022df4 commit 18c1b30
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 1 addition & 4 deletions app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ def create
@subscription = EmailSubscription.new(subscription_params)

if @subscription.save
#SubscriptionMailer.confirm_email(@subscription).deliver

JobMailer.job_list_summary("xdite@xdite.net").deliver

SubscriptionMailer.confirm_email(@subscription).deliver
redirect_to new_subscription_path , :notice => "感謝您對 66K 職缺有興趣,我們會寄送一封郵件給您確認 Email 位址。"
else
render :new
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/jobs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def render_job_description(job)
end



def render_job_description_for_mail(job)
truncate(sanitize(job.description.to_markdown), :length => 250 )
end

def render_job_apply_instruction(job)
job.apply_instruction.to_markdown
end
Expand Down
7 changes: 5 additions & 2 deletions app/mailers/job_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def deliver_email_for_verification(job)
end

def job_list_summary(email)
@jobs = Job.published.where(:created_on => (Date.today - 2.days)..Date.today ).order("id DESC").limit(20)
mail(:to => email, :subject => "xxx")
start_date = Date.today - 2.days
end_date = Date.today
@jobs = Job.published.where(:created_on => (start_date..end_date)).order("id DESC").limit(20)
@title = "66K+ 工作速報 : #{start_date} ~ #{end_date} "
mail(:to => email, :subject => @title )
end


Expand Down
6 changes: 3 additions & 3 deletions app/views/job_mailer/job_list_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
<tr class="header-top">
<td>
<%= link_to(root_url) do %>
66K+ 工作網:工作速報
<%= @title %>
<% end %>
</td>
</tr>
<tr class="header-mail">
<td>
<h2><%= @title %></h2>
<h2>最新工作</h2>
</td>
</tr>
<tr class="mail-content">
<td>
<div class="digest-posts">
<%= div_for @jobs do |job| %>
<%= render_job_title(job) %>
<%= render_job_description(job) %>
<%= render_job_description_for_mail(job) %>

<p class="post-meta">
<%= render_job_salary(job.lower_bound) %> - <%= render_job_salary(job.higher_bound) %>
Expand Down

0 comments on commit 18c1b30

Please sign in to comment.