Rails 3.1.3

This must be a simple matter, but since I am stupid enough to
misunderstand something.


In a controller, I would like to create AND search for another model if
they match in terms of the properties.

  def create
    @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.exists?
      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?

soichi

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to