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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:17:55+00:00 2026-05-22T03:17:55+00:00

NoMethodError in CarController#add undefined method `user_id=’ for #<Car:0x7160c70> RAILS_ROOT: C:/Users/Jatinder/BitNami RubyStack projects/mercedes_mod 2 add.html

  • 0
NoMethodError in CarController#add

undefined method `user_id=' for #<Car:0x7160c70>
RAILS_ROOT: C:/Users/Jatinder/BitNami RubyStack projects/mercedes_mod 2
add.html (for adding car)

add.html in /views/car

<h1>Ask a Question or Discuss Your Car</h1>
<%= error_messages_for :car %>
<br>
<p>You can ask anything related to cars even if its not a Mercedes!</p>
<% form_for :car do |f| %>

  <p>
    <%= f.label :name, "Title of Question" %>
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :description, "Describe Your Question" %>
    <%= f.text_area :description %>
  </p>
  <p>
    <%= f.submit "Add" %>
  </p>
<% end %>

def add in car_controller.rb:

def add 
      @title = "Ask a New Question"
    if request.post?
       @car = Car.new(params[:car])
       @car.user_id = User.logged_in(session).id
    if @car.save
        flash[:notice] = "Car #{@car.name} added!"
        redirect_to :controller => :car, :action => :index
      end
    end
  end

car.rb model:

class Car < ActiveRecord::Base
    belongs_to :user
    belongs_to :subject
  validates_presence_of :name, :description
end

routes.rb

map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
  map.resources :car, :users => { :delete => :get }
  map.root :controller => "main"
  map.root :controller => "car", :action => "destroy"
end

create_cars migration:

class CreateCars < ActiveRecord::Migration
  def self.up
    create_table :cars do |t|
      t.interger :user_id
      t.string :name
      t.string :description

      t.timestamps
    end
  end

  def self.down
    drop_table :cars
  end
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-05-22T03:17:55+00:00Added an answer on May 22, 2026 at 3:17 am

    Your migration has a typo. You should have t.integer, not t.interger on your :user_id. Also, make sure to run rake db:migrate in your console before running your app.

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

Sidebar

Related Questions

NoMethodError in course_templates#index Showing app/views/course_templates/index.haml where line #6 raised: undefined method `new_course_template' for #<ActionView::Base:0x237c3e4>
I keep getting: NoMethodError in StudentsController undefined method `id_num=' for #<Array:0x105adcc98> I'm positive there's
When I write debugger it does not start: NoMethodError: undefined method `run_init_script' for Debugger:Module
This is the error I get: ContactPostalcardsController#skip (NoMethodError) undefined method `status=' for #<ContactPostalcard:0x2b21433d64b0> This
I get the following error: Delayed::Job SomeMailJob# (NoMethodError) undefined method `subject' for #<YAML::Object:0x2b0a191f4c78> This
I get this error when trying to register a new user. NoMethodError (undefined method
I'm getting a NoMethodError when trying to access a method defined in one of
I simply want my method call to suppress all NoMethodError exceptions that might arise
Because apparently require 'date' doesn't include the method hours or seconds etc: undefined method
>> events.first.datetime => Wed Sep 15 19:00:00 -0400 2010 >> Time.parse(events.first.datetime) NoMethodError: private method

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.