人际关系问题
您可以查看我提到的应用程序: http://github.com/585connor/QA
所以,我已经构建了这个问题&回答应用程序...有点。我可以得到 答案将列出在各自的问题上,但我不知道 了解如何让用户信息显示在这些问题/答案上。 例如,我想将用户名放在每个答案旁边,然后将 每个问题旁边的用户名。另外,在观看表演动作时 用户控制器,我希望能够看到其列表 特定用户的问题和答案。
共有三个表:问题、答案和用户。你能带一个 查看 github 存储库并尝试为我指明正确的方向 为了实现我应该采取哪些步骤/我应该学习的概念 我想做什么?
You can take a look at the app I'm referring to at:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个
如果您的问答模型中
,您可以通过在问题或答案对象上调用 .user 来访问关联的用户模型:访问用户的问题和答案类似:
Becase you have a
in your question and answer model, you can access the associated user-model by calling .user on a question or answer object:
Accessing the user's questions and answers is similar: