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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:08:45+00:00 2026-05-14T18:08:45+00:00

I have a working Rails application on version 2.3.5 – I am using many

  • 0

I have a working Rails application on version 2.3.5 – I am using many to many model relations and have got almost everything working.

What I would like to do is on my new kase page show the most recent kase job ref at the top.

So for example, if I created a new kase with a job ref of “001”, if I then went to create a new kase it would show at the top “Your previous kases reference was 001”.

I have the field of jobref in the new kase form, so I am trying to workout what I need to do to output only the last jobref.

If that makes sense!

Thanks,

Danny

EDIT: kase model.

class Kase < ActiveRecord::Base
  def self.all_latest
      find(:all, :order => 'created_at DESC', :limit => 5)
  end

  belongs_to :company # foreign key: company_id
  belongs_to :person # foreign key in join table

  # Paperclip
  has_attached_file :avatar

  # SEARCH FACILITY
  def self.search(search)
    search_condition = "%" + search + "%"
    find(:all, :conditions => ['jobno LIKE ? OR casesubject LIKE ? OR transport LIKE ? OR goods LIKE ? OR comments LIKE ? OR invoicenumber LIKE ? OR netamount LIKE ? OR clientref LIKE ? OR kase_status LIKE ? OR lyingatlocationaddresscity LIKE ?', search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition])
  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-14T18:08:46+00:00Added an answer on May 14, 2026 at 6:08 pm

    Kase.first(:order => 'id DESC')

    Or if you have a created_at column:

    Kase.first(:order => 'created_at DESC')

    There are many different ways to get what you want, and most depend on how your model is defined.

    Edit:

    Model:

    def self.most_recent
      first(:order => 'id DESC') # or whatever query you need to get the most recent
    end
    

    View:

    <% if Kase.most_recent %>
      <p>Your previous kases reference was <%= Kase.most_recent.jobref %>.</p>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 404k
  • Answers 404k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Basically, you can't, for security reasons. However, the new/upcoming File… May 15, 2026 at 5:36 am
  • Editorial Team
    Editorial Team added an answer Recently appeared Apple's technical note QA1673 describes how to pause/resume… May 15, 2026 at 5:36 am
  • Editorial Team
    Editorial Team added an answer You should initialize an ObjC instance as Rate* rate =… May 15, 2026 at 5:36 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.