Created
October 3, 2009 04:59
-
-
Save strass/200409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#routes.rb | |
new_game_topic_post GET /games/:game_id/topics/:topic_id/posts/new(.:format) {:action=>"new", :controller=>"posts"} | |
========== | |
#posts/show.html.erb | |
<%=h @topic.name %> | |
<table> | |
<tr> | |
<th width="60%">post Title</th> | |
<th width="10%">Replies</th> | |
<th width="30%">Last Post</th> | |
</tr> | |
<% @topic.posts.each do |post| %> | |
<tr> | |
<td>test</td> | |
<td>%= post.posts.count - 1 %></td> | |
<td class="right"></td> | |
<td></td> | |
<td><%= link_to "Edit", edit_post_path(@topic.id) %></td> | |
</tr> | |
<% end %> | |
</table> | |
<p><%= link_to "New post", new_game_topic_post_path(@post, @topic) %></p> | |
=========== | |
#posts_controller.rb | |
def new | |
@post = Post.new | |
@post.pic.game_id = params[:topic][:game_id] | |
@post.topic_id = params[:post][:topic_id] | |
end | |
========== | |
#ERROR: | |
New Posts link is generating: | |
/games//topics/23/posts/new | |
instead of | |
/games/1/topics/23/posts/new | |
thus: | |
No route matches "/games//topics/23/posts/new" with {:method=>:get} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment