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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:17:57+00:00 2026-06-10T11:17:57+00:00

Invoice item is a model in our rails 3.2.8 app. Its definition is: class

  • 0

Invoice item is a model in our rails 3.2.8 app. Its definition is:

class InvoiceItem < ActiveRecord::Base 

  belongs_to :invoice
  belongs_to :quote_test_item, :class_name => 'QuoteTestItem'
  belongs_to :lease_usage_record, :class_name => 'LeaseUsageRecord'

  validates :lease_usage_record_id, :uniqueness => { :scope => :invoice_id }, :unless => "lease_usage_record_id.nil?"

end

There are 3 associations. If i is an invoice item object. i.quote_test_item will create error (in rails console):

irb(main):037:0> i.quote_test_item
NameError: uninitialized constant InvoiceItem::quote_test_item

i is:

irb(main):038:0> i
=> #<InvoiceItem id: 6, invoice_id: 6, lease_usage_record_id: nil, created_at: "2012-07-25 19:28:37", updated_at: "2012-07-25 19:28:37", quote_test_item_id: 1>

But both i.invoice and i.lease_usage_record went through and did not create any error. For example:

irb(main):036:0> i.lease_usage_record
=> nil

Why only i.quote_test_item created error? Thanks so much.

  • 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-10T11:17:58+00:00Added an answer on June 10, 2026 at 11:17 am

    Make sure you have performed all migrations. You might also want to check whether your QuoteTestItem (which by the way, you don’t have to specify the :classname since its inferred) to check whether you have a corresponding has_one :invoice_item or has_many :invoice_items, depending on how your modelling it.

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

Sidebar

Related Questions

I have an Invoice model in a Rails app. The Invoice has_many Products and
I have these two models class Invoice < ActiveRecord::Base has_many :items accepts_nested_attributes_for :items ...
I have a basic invoice setup with models: Invoice, Item, LineItems. # invoice.rb class
I have a model Invoice with a method def item_objects(self): return self.invoiceitem_set.filter(kind='item') I then
I the following in the models.py: class Item(models.Model): date = models.DateField(_('date'), blank=True, null=True) description
I have some code like: <table> @foreach (var invoiceLine in Model.Invoice.InvoiceLine)) { <tr class=subheader>
I have two classes Invoice and InvoiceItem. I would like Invoice to have a
So, I have an Invoice object like so: public class Invoice { public virtual
I'm building an app in CodeIgniter. I have an invoice form which uses jQuery
I have a item tracking system which has an Item model which has a

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.