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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:32:41+00:00 2026-05-24T05:32:41+00:00

I am setting a variable in my controller but for some reason it is

  • 0

I am setting a variable in my controller but for some reason it is not getting set. I tried it two ways.

  def update
 #   @available_cars = Car_info.where("user_id = ?", session[:user_id])
    @available_cars = Car_info.find_by_user_id(session[:user_id])
  end

In my view I do this.

<% @available_cars.each do |car| %>
<%= car.name %>
<% end %>

What I intend to do is populate the @available_cars into a drop down list but I can’t even get them to print. I know the session[:user_id] is set because I print it and access it elsewhere.

I get this error…
Expected D:/RailsProjects/mileage/app/models/car_info.rb to define Car_info

in my controller
app/controllers/active_car_controller.rb:6:in `update’

Any help would be appreciated. New to RoR.

  • 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-24T05:32:42+00:00Added an answer on May 24, 2026 at 5:32 am

    You need to change your query to:

    @available_cars = Car_info.find_all_by_user_id(session[:user_id])
    

    The find_all part will get you all records, whereas find only gets you the first. Another way to write this is:

    @available_cars = Car_info.where("user_id = ?", session[:user_id])
    

    Ideally, you want your class to be called CarInfo, not Car_info.

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

Sidebar

Related Questions

I've got a choose statement that should be setting my variable but for some
Simply setting the SVN_EDITOR variable to mate does not get the job done. It
I have a Rails controller in which I am setting a instance variable -
I set the view controller to be the delegate of a local variable ASIHTTPFormDataRequest
I'm setting individual page titles in my controllers' actions using: $this->set( 'title_for_layout', 'Some Title'
I have 2 controllers, I am setting a session variable in one controller and
How can I have a dynamic variable setting the amount of rows to return
I am working in flex and I am just setting a variable to false.
I must be overlooking something simple. I'm setting a variable from a query result
I am copying a file to a directory, and then setting an environment variable

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.