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

  • Home
  • SEARCH
  • 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 374019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:21:53+00:00 2026-05-12T14:21:53+00:00

I have is an application can be accessed from 2 different URLs and looks/behaves

  • 0

I have is an application can be accessed from 2 different URLs and looks/behaves slightly different depending on which URL you use to access it. I’m able to do this by storing a value in the session object and basing some decisions off of it such as which path views get loaded from.

This sort of approach seemed like it would work until I needed to have different URL’s sent out in emails. In a class that inherits from ActionMailer, I need to set the default_url_options[:host] based on the value of a session variable. Rails throws the following error when I call session from anywhere within the mailer:

undefined local variable or method `session’ for ApplicationMailer:Class

The less-than-desirable way to handle this is to pass the session variable into my mailer calls. I’d rather not do this as it doesn’t seem very DRY and would require changes to much of my code.

  • 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-05-12T14:21:53+00:00Added an answer on May 12, 2026 at 2:21 pm

    Whether you can shoehorn a reference to the session into the mailer or not, I think you’ve already hit upon the correct solution. Passing in the context you want to use would be preferable for a couple of reasons.

    1. The mailer probably shouldn’t know about the session in the first place.
    2. Assume that someday you have to send a lot of mail, and batch process it. You’ll be right back to where you are now — having to pass in your context.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wicket application which can be deployed in different environments. One of
I have an ASP.Net 4.0 web application which very frequently loads data from the
I have an application that can filter a datagridview based on date using a
I have an application that can be viewed with landscape and portrait mode. I'm
I have an application that can potentially have hundreds of memory mapped, i.e., mmap()
In C++, a console application can have a message handler in its WinMain procedure,
I have a java application that can be run as a JFrame or as
I have an application where user can download documents. User has option to download
I have an application where users can upload video files of any size, and
I have an application where users can store items. Now each type of account

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.