I am optionally creating User with Nested attributes. I just want to skip confirmation email . But
class ShipperOrder < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
end
class User < ActiveRecord::Base
has_many :shipper_orders
end
controller
class ShipperOrdersController < ApplicationController
def create
@shipper_order = ShipperOrder.new(order_params)
if @shipper_order.save
flash[:notice] = "Shipper order created"
else
flash.now[:alert] = @shipper_order.errors.full_messages.join(", ")
render :error
end
end
private
def order_params
params.require(:shipper_order).permit({user_attributes: [:first_name, :email,
:last_name,:mobile_phone, :password, :terms_of_service, :password_reset_required
]}, :description)
end
end
Now i am creating an order and if user want to assign this order to a User that do not exist in database. Then i am creating that user with help of nested_attributes. Everything works fine . i just want to disable the confirmation email for such type of user.