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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:49:24+00:00 2026-05-25T10:49:24+00:00

I followed the instructions for the gem perfectly – https://github.com/jaustinhughey/vanities – and everything else

  • 0

I followed the instructions for the gem perfectly – https://github.com/jaustinhughey/vanities – and everything else worked fine.

But when I tried to load my main page, I am getting this error:

NameError in HomeController#index

undefined local variable or method `has_vanity' for #<Class:0x000001015691e8>
app/models/user.rb:2:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/home_controller.rb:3:in `index'

Here is my User.rb

class User < ActiveRecord::Base
        has_vanity

        has_many :feedbacks_as_poster, :foreign_key => :poster_id, :class_name => 'Feedback'
      has_many :feedbacks_as_receiver, :foreign_key => :receiver_id, :class_name => 'Feedback'


end
# == Schema Information
#
# Table name: users
#
#  id         :integer         not null, primary key
#  email      :string(255)
#  f_name     :string(255)
#  l_name     :string(255)
#  username   :string(255)
#  role_id    :integer
#  picture    :string(255)
#  about_me   :string(255)
#  website    :string(255)
#  created_at :datetime
#  updated_at :datetime
#

And here is my Home Controller

class HomeController < ApplicationController
  def index
        @users = User.all
        @feedback = Feedback.new
  end

end

Thoughts?

Edit 1: See my Gemfile below:

source 'http://rubygems.org'

gem 'rails', '3.1.0'

gem 'execjs'
gem 'therubyracer'
gem 'vanities'

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

gem 'jquery-rails'    

group :development do
    gem 'sqlite3'
    gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
end

group :test do
  gem 'turn', :require => false
end

group :production do    
    gem 'pg', :require => 'pg'
end

Edit 2: If I go to the URL profile of a user I have created, e.g. localhost:3000/test I see the following error, which leads me to believe that part of the gem is working because it actually fetches the correct record. But something else is broken.

Started GET "/test" for 127.0.0.1 at 2011-09-07 20:00:19 -0500
  Processing by VanitiesController#show as HTML
  Parameters: {"vname"=>"test"}
  Vanity Load (0.2ms)  SELECT "vanities".* FROM "vanities" WHERE "vanities"."name" = 'test' LIMIT 1
Completed 500 Internal Server Error in 100ms

NameError (undefined local variable or method `has_vanity' for #<Class:0x0000010313d478>):
  app/models/user.rb:2:in `<class:User>'
  app/models/user.rb:1:in `<top (required)>'
  app/controllers/vanities_controller.rb:8:in `show'
  • 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-25T10:49:24+00:00Added an answer on May 25, 2026 at 10:49 am

    I’ve tried to duplicate this problem on my end, and I can’t seem to get it to duplicate, meaning it’s possibly something unique to your application that may be causing the issue.

    You can reference https://github.com/jaustinhughey/vtest for a working example.

    What I find interesting about your problem is this:

    undefined local variable or method `has_vanity’ for #<Class:0x000001015691e8>

    Shouldn’t that be “User”, not “Class”? Vanities works by pushing up the polymorphic association for an object and a vanity into ActiveRecord as an available method. Then you simply call “has_vanity” to automatically have that polymorphic association available for you. It’s a simplistic way to get it in there – only a shortcut, really.

    I’m wondering if there’s something else “funky” that’s being done to/with ActiveRecord in your case. I’m not sure what specifically would cause that, but for some reason that method just plain doesn’t exist for a User object in your case.

    As a work-around, you may try adding the following code in place of the call to “has_vanity”:

    class User < ActiveRecord::Base
      has_one :vanity, :as => :vain # instead of has_vanity
    
      has_many :feedbacks_as_poster, :foreign_key => :poster_id, :class_name => 'Feedback'
      has_many :feedbacks_as_receiver, :foreign_key => :receiver_id, :class_name => 'Feedback'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just tried the ruby-graphviz gem ( http://github.com/glejeune/Ruby-Graphviz ). I followed the instructions (installed
i have followed instructions found on https://github.com/coderifous/jquery-localize , and for testing purpose i have
I followed the instructions here http://support.microsoft.com/kb/825532 After that when I preview my page, I
I've followed the instructions in this MSDN article: http://msdn.microsoft.com/en-us/library/dd206945.aspx Is it possible to call
I have followed the instructions found at http://code.google.com/p/pubsubhubbub/wiki/DeveloperGettingStartedGuide to setup a hub. When I
I've followed the instructions from http://www.lucidimagination.com/blog/2009/03/09/nutch-solr/ Had solr up and running before that, could
I followed the instructions in this site but there's no such code inside the
I have followed instructions verbatim using border:none and background:transparent, but a border still shows
Followed instructions on Railscast but can't get server to start. It states the following
I followed the instructions on ADT Plugin for Eclipse but I got this message

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.