undefined method `id' for #<Property::ActiveRecord_Relation
associations, rails-activerecord, ruby-on-rails-4
Solution
As I said, `where` returns an `Active Record` relation which is an `array`. Try the below
raise @property.first.id
or
Change this
@property = Property.where(owner_id: @owner)
to
@property = Property.find_by(owner_id: @owner)
Problem
Sorry for dumb question Here when I am raising `@property` I am getting row but when I am raising `@property.id` it's showing `undefined method id` give me conclusion about this in `owner.rb` ``` has_many :properties ``` in `property.rb` ``` belongs_to :owner ``` in owners_controller.rb ``` def new user = User.friendly.find(current_user.slug) @owner = user.owner authorize @owner @property = Property.where(owner_id: @owner) #raise @property.id.inspect @renter = User.friendly.find(params[:renter_id]).renter @message = Message.new(renter_id: @renter.id, owner_id: @owner.id,property_id: @property.id) end ``` Thanks in advance