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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:49:46+00:00 2026-05-15T05:49:46+00:00

I have a model called Kase each Case is assigned to a contact person

  • 0

I have a model called Kase each “Case” is assigned to a contact person via the following code:

class Kase < ActiveRecord::Base
  validates_presence_of :jobno
  has_many :notes, :order => "created_at DESC"

  belongs_to :company # foreign key: company_id
  belongs_to :person # foreign key in join table
  belongs_to :surveyor,
             :class_name => "Company",
             :foreign_key => "appointedsurveyor_id"
  belongs_to :surveyorperson,
             :class_name => "Person",
             :foreign_key => "surveyorperson_id"

I was wondering if it is possible to list on the contacts page all of the kases that that person is associated with.

I assume I need to use the find command within the Person model? Maybe something like the following?

def index
@kases = Person.Kase.find(:person_id)

or am I completely misunderstanding everything again?

Thanks,

Danny

EDIT:

If I use:

@kases= @person.kases

I can successfully do the following:

<% if @person.kases.empty? %>
  No Cases Found
<% end %>

<% if @person.kases %>
 This person has a case assigned to them
<% end %>

but how do I output the “jobref” field from the kase table for each record found?

  • 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-15T05:49:47+00:00Added an answer on May 15, 2026 at 5:49 am

    Maybe following will work:

    @person.kase.conditions({:person_id => some_id})
    

    where some_id is an integer value.

    Edit

    you have association so you can use directly as follows:

    @kases= @person.kases
    

    in your show.rhtml you can use instance variable directly in your .rhtml
    also @kases is an array so you have to iterate over it.

       <% if @kases.blank?  %>
        No Kase found.
       <% else %>
         <% for kase in @kases %>
           <%=h kase.jobref %>
         <% end %>
       <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model called Category which looks like this: class Category < ActiveRecord::Base
I have a model called affiche and model user class User < ActiveRecord::Base has_many
I have a model called Contact which has_one guest like so. class Contact <
I have a number of records in a model called Kases, each kase record
I have a Model called blog_model. The code for its constructor is below: class
I have a model called UserProfile defined as class UserProfile(models.Model): user = models.OneToOneField(User, related_name='userprofile_from_user')
I have a model called company that has_many users then users belongs_to company. class
I have a model called Customer in google app engine with python: class Customer(db.Model):
I have three models that I want to interact with each other. Kase, Person
I have a model called Vote and this is what vote.rb looks like: class

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.