# Issues with Relationships

**URL:** <https://www.ruby-forum.com/t/issues-with-relationships/194361>\
**Category:** Rails\
**Created:** [September 3, 2010, 2:27am UTC](https://www.ruby-forum.com/t/issues-with-relationships/194361 "2010-09-03T02:27:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fiveeightfive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@fiveeightfive](https://www.ruby-forum.com/u/fiveeightfive)\
**Post date:** [September 3, 2010, 2:27am UTC](https://www.ruby-forum.com/t/issues-with-relationships/194361/1 "2010-09-03T02:27:51Z")

</div>

You can take a look at the app I’m referring to at:  
[http://github.com/585connor/QA](http://github.com/585connor/QA)

So, I’ve built this question & answer app… kind of. I can get the  
answers to be listed on their respective questions but I cannot figure  
out how to get the user info to be displayed on those questions/answers.  
For example I’d like to put the username next to each answer and the  
username next to each question. Also, when viewing the show action of  
the users controller, I’d like to be able to see a list of that  
particular user’s questions and answers.

There are three tables: questions, answers and users. Can you take a  
look at the github repository and try to point me in the right direction  
for what steps I should take/concepts I should learn in order to achieve  
what I’m trying to do?

---

<div class="post-metadata">

**Author:** ![fiveeightfive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@fiveeightfive](https://www.ruby-forum.com/u/fiveeightfive)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/issues-with-relationships/194361/2 "2010-09-06T16:39:25Z")

</div>

On 3 September 2010 01:27, Connor B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can take a look at the app I’m referring to at:  
> [http://github.com/585connor/QA](http://github.com/585connor/QA)
> 
> So, I’ve built this question & answer app… kind of. I can get the  
> answers to be listed on their respective questions but I cannot figure  
> out how to get the user info to be displayed on those questions/answers.  
> For example I’d like to put the username next to each answer and the  
> username next to each question. Also, when viewing the show action of  
> the users controller, I’d like to be able to see a list of that  
> particular user’s questions and answers.
> 
> There are three tables: questions, answers and users. Can you take a  
> look at the github repository and try to point me in the right direction  
> for what steps I should take/concepts I should learn in order to achieve  
> what I’m trying to do?

I may be wrong but I think you may find it difficult to get someone  
to go to the trouble of looking at your whole app in order to  
understand your problem. For me, at least, you would be better to  
provide the model relationships (has\_many, belongs\_to etc) and try and  
reduce your problem to it’s simplest level. The less extraneous  
detail the better. So for example exactly where you want to show the  
username is not relevant to the question, I think what you want to ask  
is ‘if I have an answer how do I determine the username for that  
answer?’ That depends only on the model relationships. It is even  
possible that in the act of trying to refine exactly what question you  
are trying to ask you might well realise that you know the answer  
already.

Have you read the Rails Guides on ActiveRecord Associations? That may  
well help.

Colin
