title: How to fetch attribute values from a 'first' or 'last' record in Rails?
body: <p>I am trying to fetch a column value of last record in Activerecord,
  from following.</p>
  
  <pre><code>2.2.4 :025 &gt;   Equipment.last
    Equipment Load (1.0ms)  SELECT  `equipment`.* FROM `equipment`  ORDER BY `equipment`.`id` DESC LIMIT 1
   =&gt; #&lt;Equipment id: 7, identifier: "LID-0000007", country_id: 99, state_id: 99, city_id: 99, listing_type: 3, title: "Mix", category_id: 1, sub_category_id: 2, manufacturer_id: 1, model: "ds323", serial_no: "232", year: 2011, condition: 4, other_condition: "", status: 4, other_status: "", price: #&lt;BigDecimal:3d1b1d8,'0.32323E5',9(18)&gt;, weight: nil, weight_units: nil, height: nil, height_units: nil, width: nil, width_units: nil, length: nil, length_units: nil, quantity_available: 1, name_plate_capactiy: nil, name_plate_capactiy_units: "", voltage: "", frequency: nil, phase: nil, current: "", current_units: nil, hours_worked: "", place_of_manufacturing: "", description: "", selling_status: 1, created_at: "2017-02-28 10:15:43", updated_at: "2017-02-28 10:16:30", user_id: 4, wanted_equipment_id: 5, is_read_after_active: false, slug: "mix"&gt; 
  </code></pre>
  
  <p>I'm trying to fetch <code>category_id</code> of the last record.</p>
  
  <pre><code>Equipment.last.pluck(:category_id)
  </code></pre>
  
  <p>I think I am doing it wrong. Could somebody please tell me. How it is done?</p>