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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:50:04+00:00 2026-06-11T05:50:04+00:00

Here is my unaltered controller: def create @user = User.new(params[:user]) respond_to do |format| if

  • 0

Here is my unaltered controller:

  def create
    @user = User.new(params[:user])

    respond_to do |format|
      if @user.save
        format.html { redirect_to @user, notice: 'User was successfully created.' }
        format.json { render json: @user, status: :created, location: @user }
      else
        format.html { render action: "new" }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

And here are my routes:

  root :to => "songs#index"
  match '/votes/:song_id/:user_id' => "votes#create"
  resources :votes

  resource :session

  resources :users

  resources :songs

  match '/login' => "sessions#new", :as => "login" 
  match '/logout' => "sessions#destroy", :as => "logout" 

And the error:

undefined method `user' for #<User:0x00000102b42a00>


Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:46:in `block in create'
app/controllers/users_controller.rb:45:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"oOzmpsbEJtnHC4YGeAf4N6pVxfK+Zf4W9ec+0E/Eds0=",
 "user"=>{"email"=>"bhjjhb@hui.com",
 "password"=>"[FILTERED]"},
 "commit"=>"Create User"}

model:

class User < ActiveRecord::Base
  attr_accessible :email, :password
  validates_uniqueness_of :user
  validates_presence_of :password

  has_many :votes


end
  • 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-11T05:50:06+00:00Added an answer on June 11, 2026 at 5:50 am

    http://guides.rubyonrails.org/active_record_validations_callbacks.html#uniqueness

    This helper validates that the attribute’s value is unique

    Your problem is in your validations; validates_uniqueness_of checks the uniqueness of a model attribute, so validates_uniqueness_of :user is trying to check that the user’s user attribute is unique. In the process, it calls @user.user, which produces the NoMethodError.

    Edited to add: As @Amar says, the way to fix this is by validating the uniqueness of some attribute or set of attributes that will be unique for each user record (such as :email).

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

Sidebar

Related Questions

Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my problem : I have a post controller with the action create.
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here's my procedure: DROP PROCEDURE IF EXISTS `couponExpires`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `couponExpires`(IN couponID BIGINT,
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is an example: I write html code inside of textarea, then I swap
Here's the problem: user is presented with a text field, unto which may he
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here is what is supposed to happen: The moment the user chooses an option
Here is the HTML <a style=border: medium none; display: block; class=agendaNav href=#><img class=rightArrow src=/images/arrowdown.png>

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.