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

- 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
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!