pluck and select

  • pluck return Array object as the result
  • select return ActiveRecord::Relation object as the result
  • select always returns id: nil property in your ActiveRecord results if you don't select :id. For converting your object to json without id:nil, you could do as following: record(s).to_json(only:[:column1, :column2, ...:column3])
    photos = Photo.select(:name, :path_original, :path_small)
    respond_with photos.to_json(only: [:name, :path_original, :path_small])
    

Reference

results matching ""

    No results matching ""