Quantcast
Channel: Rails show latest entry - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Rails show latest entry

$
0
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])  endend

Viewing all articles
Browse latest Browse all 2

Trending Articles