Find :include and :joins?

Hello there,

I facing some problems with :include, I want to be able to use the
:select method or I will end up using the :joins :frowning:

JOINS =>
find(:first, :select => “messages.*, users.id as nid, users.nickname”,
:conditions => [“messages.id = ? AND messages.user_from_id = ?”,
id, user_id],
:joins => “LEFT JOIN users ON users.id = messages.user_from_id”)

INCLUDE =>
find(:first, :conditions => [“messages.id = ? AND messages.user_from_id
= ? AND messages.deleted_from_id = ?”, id, user_id, false],
:include => [:to])

The join let me get the nickname by typing
@message.nickname (Baad)

The include let me get the nickname by typing
@message.to.nickname (This is the way I prefer)

So how I can use the :include and still NOT receive all the information
from the :to table? Because I want to be able to use the
@message.to.nickname instead of @message.nickname

//Thanks for all the help :smiley:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs