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 3807180
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:57:02+00:00 2026-05-19T14:57:02+00:00

The url_helpers do not seem to be working in my User model during an

  • 0

The url_helpers do not seem to be working in my User model during an after_create callback. Here is the error…

NameError in Devise/registrationsController#create

undefined local variable or method `controller’ for…

class User < ActiveRecord::Base

  include ActionView::Helpers::UrlHelper
  include Rails.application.routes.url_helpers

  # Include default devise modules. Others available are:
  # :token_authenticatable, :lockable and :timeoutable
  devise :invitable, :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable
...
# Callbacks
after_create :initialization

  def initialization
if self.temp_org_id.blank?
  self.update_attributes(:email_messages => true, :email_requests => true)
  self.is_travel_planner ? buyer = true : buyer = false


##### THIS IS WHERE IT BREAKS##########################
step_1 = link_to('Setup your personal profile', edit_user_path(self))

  step_2 = link_to('Setup/update your company profile', '/organizations/new?user_id=' + self.id.to_s)
  if buyer == true
    step_3 = link_to "Find potential suppliers by name, location, person, and more!", "/organizations/new?user_id=" + self.id.to_s
  else
    step_3 = link_to "Make Connections with qualified buyers!", "/organizations/new?user_id=" + self.id.to_s
  end
  name = self.name_first
  type = 'suppliers'
  content = "<p>Welcome #{name},</p>
<p>The iTourSmart community is built upon a powerful web-based tool that allows you to find and connect with #{type} like never before.  Building your business with iTourSmart is as easy as 1-2-3!</p>
<h4>Step 1: Setup your personal profile</h4>
<h4>Step 2: #{step_2}</h4>
<h4>Step 3: #{step_3}</h4>
<p>=Of course, you can simply close this window and look around right now.  This message is stored in your message center and can be accessed at any time.</p>"

      new_note = self.notes.create(:is_fancybox_autoload => true, :is_sysmessage => true, :subject => "Setup your brand", :body => content)
    else
      self.roles.create(:user_id => self.id, :organization_id => self.temp_org_id)
      self.update_attributes(:temp_org_id => nil, :email_messages => true, :email_requests => true)
    end
  end
end 

Any help is greatly appreciated!

  • 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-19T14:57:03+00:00Added an answer on May 19, 2026 at 2:57 pm

    Url helpers don’t work in AR models full stop, nevermind in callbacks. This is by design- your model layer should be able to operate outside of the context of a web server.

    You can fudge the issue by including bits of the web stack in to the model and there are several questions on SO that will tell you how.. The first one in the related list for this question is:

    Can Rails Routing Helpers (i.e. mymodel_path(model)) be Used in Models?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need such a construction: form_for Project.new where Project is a model, that's not
I cant seem to get CI2's captcha helper to work... Can someone point out
I'm working on making an image server that is similar to that of Flickr's.
I'm using Android to read a document off the net, surprise I'm writing here
So I'm trying to use a Rails URL helper ( page_url ) to create
I'm trying to validate the contents of some files through a web interface and
While running my app, LogCat suddenly shows this barrage of orange-colored messages (warnings) which
I am trying to configure CKEditor but I get the following in my source,
I'm still trying to figure out a way to get a mobile site running.
How should I format a path so it works with MVC routing in jQuery?

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.