FAQ
Ok so I am having a bit of an issue getting this simple task to function
properly and am hoping someone has some advice for me, any help is greatly
appreciated!

I have created a new mailer method in *user_mailer.rb*

def *welcome_email*(user)
       @user = user

       subject = "Welcome"
       mail(:to => "greg@example.com",
            :subject => subject)
end

and I have added it to the *user_registrations_controller.rb*

# POST /resource/sign_up
   def create
     @user = build_resource(params[:user])
     if resource.save
       set_flash_message(:notice, :signed_up)
       sign_in(:user, @user)
       fire_event('spree.user.signup', :user => @user, :order =>
current_order(true))
       sign_in_and_redirect(:user, @user)
       *UserMailer.welcome_email(@user).deliver*
     else
       clean_up_passwords(resource)
       render :new
     end

It seems to work fine on my local machine but I get this error when it it
tested on my *Heroku* staging app

NameError (uninitialized constant
Spree::UserRegistrationsController::UserMailer):
  app/controllers/spree/user_registrations_controller.rb:23:in `create'

any thoughts?

Search Discussions

  • Greg Murray at Jun 10, 2013 at 8:49 pm
    Oh... I am using Spree v1.1.1

    -Thanks
    On Monday, June 10, 2013 1:48:57 PM UTC-7, Greg Murray wrote:

    Ok so I am having a bit of an issue getting this simple task to function
    properly and am hoping someone has some advice for me, any help is greatly
    appreciated!

    I have created a new mailer method in *user_mailer.rb*

    def *welcome_email*(user)
    @user = user

    subject = "Welcome"
    mail(:to => "greg@example.com",
    :subject => subject)
    end

    and I have added it to the *user_registrations_controller.rb*

    # POST /resource/sign_up
    def create
    @user = build_resource(params[:user])
    if resource.save
    set_flash_message(:notice, :signed_up)
    sign_in(:user, @user)
    fire_event('spree.user.signup', :user => @user, :order =>
    current_order(true))
    sign_in_and_redirect(:user, @user)
    *UserMailer.welcome_email(@user).deliver*
    else
    clean_up_passwords(resource)
    render :new
    end

    It seems to work fine on my local machine but I get this error when it it
    tested on my *Heroku* staging app

    NameError (uninitialized constant
    Spree::UserRegistrationsController::UserMailer):
    app/controllers/spree/user_registrations_controller.rb:23:in `create'

    any thoughts?
  • Greg Murray at Jun 13, 2013 at 10:30 pm
    Thanks Ryan.

    Unfortunately adding require_dependency 'spree/user_mailer' gives me the
    same error I was originally having on Heroku now on my local machine.

    NameError (uninitialized constant Spree::**UserRegistrationsController::**
    UserMailer):
      app/controllers/spree/user_**registrations_controller.rb:**23:in `create'


    Any other thoughts? I really don't understand why this is breaking. Any
    help as always is much appreciated.

    -Greg
  • Weston Platter at Jun 14, 2013 at 6:19 pm
    Gregg - How about adding the "Spree::" namespace to explicitly tell Rails
    where to get the class?

    *
    Spree::UserMailer.welcome_email(@user).deliver

    *
    On Thursday, June 13, 2013 4:30:17 PM UTC-6, Greg Murray wrote:

    Thanks Ryan.

    Unfortunately adding require_dependency 'spree/user_mailer' gives me the
    same error I was originally having on Heroku now on my local machine.

    NameError (uninitialized constant Spree::**UserRegistrationsController::**
    UserMailer):
    app/controllers/spree/user_**registrations_controller.rb:**23:in `create'


    Any other thoughts? I really don't understand why this is breaking. Any
    help as always is much appreciated.

    -Greg

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJun 10, '13 at 8:49p
activeJun 14, '13 at 6:19p
posts4
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Greg Murray: 3 posts Weston Platter: 1 post

People

Translate

site design / logo © 2022 Grokbase