Given this code, and assuming @user is an instance of User that has an assigned location, which choice would be used to return the user’s city?
class Location < ActiveRecord::Base
# has database columns for :city, :state
has_many :users
end
class User < ActiveRecord::Base
belovngs_to :location
delegate :city, :state, to: :location, allow_nil: true, prefix: true
end1.@user.user_city
2.@user.location_city
3. @user.city
4. @user.try(:city)
Answer:1
Posted Date:-2022-09-17 04:36:25