I am working on an app that is tightly being integrated in with Mandrill (MailChimp's transactional email service) and I am trying to override the Devise Mailer but for some reason when I send off the API call to Mandrill I receive their email, but Devise also sends me an email (which is blank).
Here is my DeviseMailer
class MyDeviseMailer < Devise::Mailer
def reset_password_instructions(record)
mandrill = Mandrill::API.new("#{MandrillConfig.api_key}")
mandrill.messages 'send-template',
{
:template_name => 'Forgot Password',
:template_content => "",
:message => {
:subject => "Forgot Password",
:from_email => "test#test123.com",
:from_name => "Company Support",
:to => [
{
:email => record.email
}
],
:global_merge_vars => [
{
:name => "FIRST_NAME",
:content => record.first_name
},
{
:name => "FORGOT_PASSWORD_URL",
:content => "<a href='#{edit_user_password_url(:reset_password_token => record.reset_password_token)}'>Change My Password</a>"
}
]
}
}
#We need to call super because Devise doesn't think we have sent any mail
super
end
end
The call to super I found here: http://qnundrum.com/answer.php?q=254917
I was running into a similar issue.
Did you update the devise initializer file (devise.rb) to specify the following:
config.mailer = "MyDeviseMailer"
You also needed to move any and all files in views/devise/mailer to views/mydevisemailer.
I would also restart your server.
Related
I saw a feature in Ext JS document - http://dev.sencha.com/deploy/ext-4.0.1/examples/grid/locking-grid.html. We can lock a column by set the option "locked" according the document, but when I did this in Netzke Grid, the grid disappears. Is there any specific method to achieve this. Below the sample code is given,
def configure(c)
super
c.model = "Product"
c.title = "Product List"
c.columns = [
{
:name => :name,
:text => "Name",
:read_only => true,
:locked => true
},
{
:name => :price,
:text => "Price"
},
{
:name => :date,
:text => "Date"
}
]
end
I've spent the last day trying to get this to work in my Rails app, but continually get the response:
{"code"=>"E-C-343", "message"=>"Unrecognized JSON Request."}
BancBox's Documentation is pretty light, so I'm at a bit of an impasse on how to solve this.
Does anyone have an example of a successful API call to createClient at BancBox utilizing REST?
My Post API call utilizing HTTParty:
include HTTParty
format :json
def save_with_bancbox(params = {})
post_params = { :authentication => { :apiKey => BANCBOX_KEY,
:secret => BANCBOX_SECRET
},
:subscriberId => BANCBOX_ID,
:firstName => params[:first_name],
:lastName => params[:last_name],
:ssn => params[:ssn],
:dob => params[:dob],
:address => { :line1 => params[:address_line_1],
:line2 => params[:address_line_2],
:city => params[:city],
:state => params[:state],
:zipcode => params[:zipcode]
},
:homePhone => params[:dob],
:email => params[:email]
}
response = HTTParty.post( BANCBOX_REST_URL,
:body => post_params)
logger.debug "Response -- #{response}"
save!
end
Please try the below code after changing apikey, secret and subscriberid
require "net/https"
require 'rubygems'
require 'json'
require 'httparty'
###########################bancbox.rb in config/initializers#################
BANCBOX_API_KEY = "__KEY__"
BANCBOX_API_SECRET = "__SECRET__"
BANCBOX_SUBSCRIBER_ID = "__SUB_ID__"
BANCBOX_API_URL = "https://sandbox-api.bancbox.com/BBXPortRest"
module Bancbox
class API
include HTTParty
debug_output $stdout
base_uri "#{BANCBOX_API_URL}"
def initialize(u=BANCBOX_API_KEY,p=BANCBOX_API_SECRET)
auth = {:apiKey => u, :secret => p}
#options = {:body => {:authentication =>auth,:subscriberId=>BANCBOX_SUBSCRIBER_ID}, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }}
end
#USERS
def create_client(options={})
options = options.merge(#options[:body])
#options.merge!({:body => options.to_json})
response = self.class.post("/createClient",#options)
#required_fields- subscriberId,firstName,lastName,ssn,dob,address,homePhone,email
end
def get_schedules(options={})
#options.merge!({:query => {:subscriberId => BANCBOX_SUBSCRIBER_ID}})
#options.merge!({:query => options})
self.class.post("/getSchedules",#options)
end
end
end
b = Bancbox::API .new
b.create_client({:firstName=> "Bipen",:lastName=> "Sasi",:ssn=>"334-444-4444",:dob=> Date.parse("January 1st 1988"), :address=>{:line1=> "4408 walnut st", :line2=>"apt 3r",:city=> "philly",:state=>"pa",:zipcode=>"19110"}, :homePhone=> "2672551161",:email=>"bipen#lokalty.com"})
I think you should POST the request to
https://sandbox-api.bancbox.com/BBXPortRest/createClient
instead of
https://sandbox-api.bancbox.com/BBXPortRest/
Also make sure to set the content type as application/json
In general, you post your request to https://sandbox-api.bancbox.com/BBXPortRest/<method>
Is there any easy way to include the multiupload feature to NetzkeFormView or GridView(AddInForm)?
My current image uloading field with carrierwave is:
{:name => :image_link, :xtype => :displayfield, :display_only => true, :getter => lambda { |r| %Q(<a href='#{r.image.url}'>Download</a>) if r.image.url }},
{:name => :image, :field_label => "Upload image", :xtype => :fileuploadfield, :getter => lambda { |r| "" }, :display_only => true}
facing problem in action mailer.
my mailer is
def registration_confirmation(user)
subject "Password Reset Instructions"
from "sender_email_id#test.com"
recipients user.email
content_type "text/html"
body "RESET your Password"
end
Settings for mailer are
require 'development_mail_interceptor'
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.in",
:user_name => "admin#domain.in",
:password => "PASSWORD",
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
and my controller is UserMailer.registration_confirmation(#new_user).deliver
The mail is not going to the user.email , it is always going to admin#domain.in
I am using mail-v 2.2.19 and rails 3.0.9
please help.
try adding this line(works for me):
mail(:to => user.email, :subject => "Password Reset Instructions")
to your registration_confirmation method
def registration_confirmation(user)
from "sender_email_id#test.com"
content_type "text/html"
body "RESET your Password"
mail(:to => user.email, :subject => "Password Reset Instructions")
end
I want to validate the email only if the email has been entered.
I tried the following:
validates :email, :presence => {:message => "Your email is used to save your greeting."},
:email => true,
:if => Proc.new {|c| not c.email.blank?},
:uniqueness => { :case_sensitive => false }
However this does not work as it stops error messages from showing when the email is left blank.
How can I validate the presence of the email when it is missing and ONLY validate the format when it has been entered?
This should do the trick.
validates :email,:presence => {:message => "Your email is used to save your greeting."}, :allow_blank => true,:uniqueness => { :case_sensitive => false }
Use:allow_blank => true or :allow_nil => true, :if => :email?
edit: fix typo.
You can write custom validation function:
class Model < ActiveRecord::Base
validate :check_email
protected
def check_email
if email.blank?
validates :email, :presence => {:message => "Your email is used to save your greeting."}
else
validates :email,
:email => true,
:uniqueness => { :case_sensitive => false }
end
end
end
or divide your validator into 2 separate validators with conditions:
validates :email,
:presence => {:message => "Your email is used to save your greeting."},
:if => Proc.new {|c| c.email.blank?}
validates :email,
:email => true,
:uniqueness => { :case_sensitive => false }
:unless => Proc.new {|c| c.email.blank?}
you can validate format if no precense required
:allow_nil => true