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IkSEKjYk1Wmqz3A43298noYz
BEdm/fCb4Q3QiOgzz7/g0pMFBTPiL9ozBN9X3pC/hxeWHgGmjjR2l94I4g+m9Bc9
PiqN/tfRxJ6I43YM61KOHjpppgxDgnOBy3Wot21U3A53klK1K7aN2z5Zf65NxOlT
QbkXbEsnzDGUZnaNT3mMI13rtRjF8GVS53bVAY0l2mZlBKsAEQEAAYkCJQQYAQIA
DwUCUj6k4AIbDAUJCWYBgAAKCRA5h0t8kuNr/8rcD/96mfB9uO+9Y2T3OBDmFng/
gI/HWiJdQezc/tjfHY4qwzp4nWmT5PbcLztvqrQbayYunU3DTAA9dyv2pfj/XqMI
+UCeUaksM+T8JAyJBK0p+6tr1h7xYzPK+rFwPjJotVcEBk+orDMqOInM3Wh4xqWJ
IFjJQikm/w3qn2CxHrJxDhNAt0sCGYU+Wtu8iKk0d5IqwBChWUlQTV5NhJmWx5wj
+RqNvVBWXaK3R0G0Zak78tICytb8Zhj/+yFdH54EMF664rENdRnWARWZjUY2eeMf
bnQq3wZoXQnA2eDBC6thusGfE6DtAhcRRWV6T53Mr3u2JbQh3l1Ly8ix8Is2bluB
HgNOw4xhO8lihfN3l1IVTJ5jTZfw0V+IsvFxCo+J5zwh4W6tOw4eJ6PLWNTmMOUu
weBFTvClRKokvZq7clIGL9foUEit04BECoHEksJBODOOIO3fSwPW87A/VIhjfRFT
xns0hhNV2vnW4Ysegi3GQl69r5alVb9b/Rs9XKvuS5rh1LKVMdksPbFrOD/nOfqI
/83ImjPaAHMc2ST9z4SHl7lP1ic4pGG2AJywoo1qU414IjiplPhLbIr1Bm7cuh/E
bDE8Q9gkRVBPiDhuqFLAgZsxnGcAQYutGyxG9VJx20xT9DfMOnP++x47uTD+1mE6
hUA8gCKDycwg2Uf2xZnRQw==
=VzOc
-----END PGP PUBLIC KEY BLOCK-----
Hello everyone,

I'm a newbie following the
http://guides.rubyonrails.org/getting_started.html , so far everyone is
working without problems except a modification that I made earlier.

I've created a view called welcome that act as main content page where I
list all the posts, going a bit further I created a new model called
comments with its own controller. At this point I'm stuck because I'm
unable to include the comments into the welcome/index view.


This is the content of comments_controller.rb


class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment].permit(:commenter,
:body))
redirect_to post_path(@post)
end
end



And this is the welcome/index.html.erb

<h1>My posts</h1>

<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>

<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.text %></td>
<td><%= link_to 'View/Post Comments', post %></td>

</tr>
<% end %>
</table>


<p>
<%= link_to "Admin", controller: "posts" %>



Any clue how to include the comments into the index page?


Sorry again for the noob question.

Phillip


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/529E0566.4090805%40bailey.st.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment