- Online Exam Test Papers | - MCQs[multiple choice questions and answers ] | - Mock Test Papers | - Practice Papers | - Sample Test Papers |

Question:
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
end

1.@user.user_city

2.@user.location_city

3. @user.city

4. @user.try(:city)

Posted Date:-2022-09-17 04:36:25


More MCQS Questions and answers

Search