This must be a simple matter, but since I am stupid enough to
In a controller, I would like to create AND search for another model if
they match in terms of the properties.
@take = current_user.takes.build(params[:take])
# search for matches
@result = Item.where(:flight_name => @take.flight_name,
:flight_num => @take.flight_num,
:departure => @take.departure,
:check_in => @take.check_in,
:weight => @take.weight)
if @result.user_id != current_user.id #<---HERE!!!!
I need to check if the searched 'Item' does not have the same 'user_id'
with the current logged-in user.
So I need to get the 'user_id' field of @result.
But certainly, putting '@result.user_id' gives an error.
How was I supposed to get 'user_id' from the @result object?