# :joins help

**URL:** <https://www.ruby-forum.com/t/joins-help/184770>\
**Category:** Rails\
**Created:** [March 8, 2010, 11:30am UTC](https://www.ruby-forum.com/t/joins-help/184770 "2010-03-08T11:30:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 8, 2010, 11:30am UTC](https://www.ruby-forum.com/t/joins-help/184770/1 "2010-03-08T11:30:19Z")

</div>

Dear all

@policy\_logs = PolicyLog.find(:all,:joins =\> “INNER JOIN po  
licy\_logs\_receiver”

```
                                 )

```

when i inspect the @policy\_logs variable it doesnot show the joined  
table fields…

how can i get all the fields?  
Thanks for nay help

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 8, 2010, 12:34pm UTC](https://www.ruby-forum.com/t/joins-help/184770/2 "2010-03-08T12:34:33Z")

</div>

On Mar 8, 10:30 am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dear all
> 
> @policy\_logs = PolicyLog.find(:all,:joins =\> “INNER JOIN po  
> licy\_logs\_receiver”
> 
> ```
> )
> 
> ```
> 
> when i inspect the @policy\_logs variable it doesnot show the joined  
> table fields…

the select clause is select policy\_logs.\* by default. In addition the  
output of inspect() (which is what you see in the console) only ever  
shows the columns from the table itself.

Fred

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 8, 2010, 12:41pm UTC](https://www.ruby-forum.com/t/joins-help/184770/3 "2010-03-08T12:41:27Z")

</div>

Thanks for the reply…  
Then how can i get associated field also…

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 8, 2010, 12:55pm UTC](https://www.ruby-forum.com/t/joins-help/184770/4 "2010-03-08T12:55:02Z")

</div>

On Mar 8, 11:41 am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the reply…  
> Then how can i get associated field also…

It’s just the output of inspect that is limited - every else works  
fine (provided you change the select clause via the :select option)

Fred

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 9, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/joins-help/184770/5 "2010-03-09T12:13:30Z")

</div>

Does Using :joins =\> “” requires association between the tables line  
belongs\_to ,hasmany like that …?

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 9, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/joins-help/184770/6 "2010-03-09T12:19:18Z")

</div>

On Mar 9, 11:13 am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does Using :joins =\> “” requires association between the tables line  
> belongs\_to ,hasmany like that …?

only if you want to use the shorthand form ( eg  
Person.find :all, :join =\> :orders)

Fred

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 9, 2010, 12:33pm UTC](https://www.ruby-forum.com/t/joins-help/184770/7 "2010-03-09T12:33:59Z")

</div>

Thanks for the reply…  
after only associating i got the associated table fields.

kindly look the below code

@policy\_logs = PolicyLog.find(:all,  
:joins =\>" join policy\_logs\_receiver as plr on policy\_logs.id =  
plr.policy\_logs\_id")

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [March 8, 2010, 1:07pm UTC](https://www.ruby-forum.com/t/joins-help/184770/8 "2010-03-08T13:07:55Z")

</div>

Just in case… you know :include don’t you?
