Hi there, I wan tto be able to allow users to invite friends...
The action below is exactly the same as the code used to send a user
their username. Only difference is, I need to change the
''''user User.find_by_email(email)'''' part as
obviously, I dont want to only
email people who are already on the site.
def invite
@title = "Invitation"
if param_posted?(:user)
email = params[:user][:email]
user = User.find_by_email(email)
if user
UserMailer.deliver_invite(@user)
flash[:notice] = "Invite sent."
redirect_to :action => "index", :controller =>
"site"
else
flash[:notice] = "There is no user with that email
address."
end
end
end
The UserMailer code is below:
def invite(user)
@subject = ''Invitation''
@body = {}
# Give body access to the user information.
@body["user"] = user
@recipients = user.email
@from =
''<do-not-reply-8Ru2MIxcQXYFQeE35raUng@public.gmane.org>''
end
The last part is the call to the UserMailer that picks the template to
send the relevant email..
UserMailer.deliver_invite(@user)
the _invite is the template in which is ultimately displayed to the
chosen invitee.
ANy ideas how this can be altered to allow for the mail to be sent to
anyone added to the input field?
Many Thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.