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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:42:01+00:00 2026-06-17T14:42:01+00:00

I have a form where a user adds a new item, and as part

  • 0

I have a form where a user adds a new item, and as part of this they choose a category for the item. The item can be a deposit or a bill, so I want two different lists they can choose from for categories since they are split up the same way. Here is my ledgeritem and itemcategory models

class Ledgeritem < ActiveRecord::Base
  attr_accessible :amount, :bankaccount_id, :deposit, :itemcategory_id, :name, :processed, :transactiondate

  attr_accessor           :balance
  attr_accessible         :balance

  belongs_to  :bankaccount 
  belongs_to  :itemcategory

end

class Itemcategory < ActiveRecord::Base
  attr_accessible :deposit, :itemcategory_id, :name, :user_id

  has_many  :ledgeritems
end

I have this in my controller. I originally had it in my model, but moved it to the controller to see if that was the problem.

@bill_categories = Itemcategory.all.where("deposit = 0")
@deposit_categories = Itemcategory.all.where("deposit = 1")

This is how I’m using it in the form

<%= f.label :itemcategory_id %><br />
<%= f.select :itemcategory_id, @bill_categories %>

And here is the error I’m getting

can't convert Symbol into Integer

I’m pretty sure it has to do with the format of my f.select, I just can’t figure out what.

  • 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-17T14:42:02+00:00Added an answer on June 17, 2026 at 2:42 pm

    You need to provide options to the f.select. You can use options_from_collection_for_select for that:

    <%= f.select :itemcategory_id, options_from_collection_for_select(@bill_categories, 'id', 'name') %>
    

    That will provide options that have a value set to the id of the objects in @bill_categories and the text that is displayed will be the name property of the objects in @bill_categories.

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

Sidebar

Related Questions

I have form where user submits field. Field can have letters, numbers, and punctuation.
If I have form where user can upload files via Ajax (and upload is
I have a search form where user can search for products within their specified
I have a form where the user can upload a zip file, it works
I have a form where a user can enter the number of students that
I have a form into which the user can add more fields to fill
I have a form where the user can dynamically add fields (clone and increasing
I have been attempting to create a form where a user can simply press
i have form with user data to input and javascript ajax to send information
in my application i have an form where user enter their username first .

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.