ruby on rails - Send devise confirmation email manually later -


i have added devise :confirmable model , created before_create skip confirmation.

before_create :skip_confirmation  def skip_confirmation   self.skip_confirmation! end 

i have mailer named store_mailer.rb along appropriate views app/views/stores/mailer/confirmation_instroctions.html.erb send out confirmation email.

class storemailer < devise::mailer   helper :application # gives access helpers defined within `application_helper`.   include devise::controllers::urlhelpers # optional. eg. `confirmation_url`   default template_path: 'store/mailer' # make sure mailer uses 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 }) |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 send confirmation email this: storemailer.confirmation_instructions(@store).deliver

but returns following error: argumenterror in transactionscontroller#create wrong number of arguments (given 1, expected 2..3)

any ideas might 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 inbox confirmation'     else      redirect_back( fallback_location: (request.referer || root_path),                  notice: "something went wrong while processing transaction. please try again!")    end  end 

confirmation_instructions method defined in devise::mailer (the superclass of storemailer class).
can see here , here, accepts 2 mandatory arguments , 1 optional.

you're invoking method passing 1 argument.
must pass second argument (token) too, following:

def create   # ...    # note: i'm not sure token need.   # it's responsibility check if it's correct.   token = @result.customer.payment_methods.first.token   storemailer.confirmation_instructions(@store, token).deliver    # ... end 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -