Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8813727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:55:53+00:00 2026-06-14T03:55:53+00:00

I am attempting to create beta invitations using the structure from railscasts episode 124,

  • 0

I am attempting to create beta invitations using the structure from railscasts episode 124, updated for rails 3.2.8.

Currently, the invitation email gets sent, but does not contain the url (which includes the invitation token) for users to follow to sign up because the instance variable I am creating in ActionMailer (@invitation_link) is nil in the view. Inspecting @invitation_link in the ActionMailer controller shows that it is pointing to the correct url, but it is nil in the view.

I have also checked out the following questions and none of the solutions have worked for me:

How do you use an instance variable with mailer in Ruby on Rails?

https://stackoverflow.com/questions/5831038/unable-to-access-instance-variable-in-mailer-view

Actionmailer instance variable problem Ruby on Rails

ActionMailer pass local variables to the erb template

Relevant code snippets below:

invitations_controller.rb

class InvitationsController < ApplicationController
  def new
    @invitation = Invitation.new
  end

  def create
    @invitation = Invitation.new(params[:invitation])
    @invitation.sender = current_user
    if @invitation.save
      if signed_in?
        InvitationMailer.invitation(@invitation).deliver
        flash[:notice] = "Thank you, invitation sent."
        redirect_to current_user
      else
        flash[:notice] = "Thank you, we will notify when we are ready."
        redirect_to root_url
      end
    else
      render :action => 'new'
    end
  end
end

in invitation_mailer.rb file

class InvitationMailer < ActionMailer::Base
  default from: "holler@thesite.com", content_type: "text/html"

  def invitation(invitation)
    mail to: invitation.recipient_email, subject: "Invitation"
    @invitation_link = invited_url(invitation.token)
    invitation.update_attribute(:sent_at, Time.now)
  end
end

views/invitation_mailer/invitation.text.erb

You are invited to join the site!

<%= @invitation_link %> # INSTANCE VARIABLE THAT IS NIL IN VIEW

routes.rb (only showing relevant line)

match '/invited/:invitation_token', to:  'users#new_invitee', as: 'invited'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:55:55+00:00Added an answer on June 14, 2026 at 3:55 am

    try this way

    This is your InvitationMailer

    def invitation(invitation)
      @invitation = invitation
      mail(:to => @invitation.recipient_email, :subject => "Invitation")
    end
    

    now, in your InvitationsController

    if signed_in?
      @invitation.update_attribute(:sent_at, Time.now)
      InvitationMailer.invitation(@invitation).deliver
      ...
    else
      ...
    end
    

    now, views/invitation_mailer/invitation.text.erb

    You are invited to join the site!
    <%= invited_url(@invitation.token) %> # INSTANCE VARIABLE THAT IS NIL IN VIEW
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a Dictionary from my DataTable. Currently i do this
I am currently attempting to create a Perl webspider using WWW::Mechanize. What I am
I attempting to create custom tabs using this . But when I try to
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
When attempting to create a new Ruby on Rails app in Windows the command
I am attempting to create an Excel spreadsheet in C#. I am using VSE
I am attempting to create a very basic login screen, using the Storyboard designer
Hi I am attempting to create a new boostrapper from my WiX generated MSI.
I am attempting to create some functionality on beta.peaksneak.com where users can basically journalize.
Im attempting to create a simple list out of some elements I stole from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.