I have added devise :confirmable
to my model and created a before_create to skip the confirmation.
before_create :skip_confirmation
def skip_confirmation
self.skip_confirmation!
end
I have a mailer named store_mailer.rb along with appropriate views app/views/stores/mailer/confirmation_instroctions.html.erb to send out the confirmation email.
class StoreMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default template_path: 'store/mailer' # to make sure that your mailer uses the devise views
end
confirmation_instroctions.html.erb
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "stores/shared/links" %>
I'm trying to send the confirmation email with this:
StoreMailer.confirmation_instructions(@store).deliver
But it returns the following error: ArgumentError in TransactionsController#create
wrong number of arguments (given 1, expected 2..3)
Any ideas what might be wrong?
Update 1
transaction_controlller.rb
def create
nonce_from_the_client = params['payment_method_nonce']
@result = Braintree::Customer.create(
first_name: params['first_name'],
last_name: params['last_name'],
:payment_method_nonce => nonce_from_the_client
)
if @result.success?
puts @result.customer.id
puts @result.customer.payment_methods[0].token
StoreMailer.confirmation_instructions(@store).deliver
redirect_to showcase_index_path, notice: 'Subscribed, please check your inbox for confirmation'
else
redirect_back( fallback_location: (request.referer || root_path),
notice: "Something went wrong while processing your transaction. Please try again!")
end
end