-
Notifications
You must be signed in to change notification settings - Fork 6
/
tell_friend_actions.rb
29 lines (27 loc) · 956 Bytes
/
tell_friend_actions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module TellFriendActions
def tell_a_friend
load_object
@mail_to_friend = MailToFriend.new(:sender_email => current_user.try(:email))
respond_to do |format|
format.html
end
end
def mail_to_friend
load_object
@mail_to_friend = MailToFriend.new(params[:mail_to_friend])
respond_to do |format|
format.html do
if @mail_to_friend.valid? &&
verify_recaptcha(:private_key => Spree::Captcha::Config[:private_key])
flash[:notice] = I18n.t('email_to_friend.mail_sent_to', :email => @mail_to_friend.recipient_email)
flash[:notice] << @template.link_to(I18n.t('email_to_friend.send_to_other'),
tell_a_friend_product_path(@product))
ProductMailer.deliver_mail_to_friend(@product, @mail_to_friend)
redirect_to product_url(@product)
else
render :tell_a_friend
end
end
end
end
end