I've tried to work through the "Getting Started" tutorial a bunch of times and I always hit a wall.
It's a great tutorial, but either there is a typo, or I am using the wrong version of either Rails or Ruby.
I am using Rails 2.3.2 and Ruby 1.8.6. The tutorial does not indicate that Ruby 1.9 is required, does anyone know if it is? I doubt it.
All my files match the tutorial. When I try to click on "Manage Comments:" on http://localhost:3000/posts/2
My browser makes the HTTP request: http://localhost:3000/posts/2/comments
I get an error that says: ActionController::RoutingError in Comments#index Showing app/views/comments/index.html.erb where line #13 raised:
post_comment_url failed to generate from {:post_id=>#<Post id: 2, name: "Jaymes Dec", title: "Come on!", content: "You can do it!", created_at: "2009-08-13 15:32:15", updated_at: "2009-08-13 15:32:15">, :controller=>"comments", :action=>"show", :id=>nil}, expected: {:controller=>"comments", :action=>"show"}, diff: {:post_id=>#<Post id: 2, name: "Jaymes Dec", title: "Come on!", content: "You can do it!", created_at: "2009-08-13 15:32:15", updated_at: "2009-08-13 15:32:15">, :id=>nil}
My index is:
<code> <h1>Comments for <%= @post.title %></h1>
<table> <tr> <th>Commenter</th> <th>Body</th> </tr>
<% for comment in @comments %> <tr> <td><%=h comment.commenter %></td> <td><%=h comment.body %></td> <td><%= link_to "Show", post_comment_path(@post,@comment)%> </td> <td><%= link_to "Edit", edit_post_comment_path(@post, @comment)%> </td> <td><%= link_to "Destroy", post_comment_path(@post, @comment), :confirm => "Are you sure?", :method => :delete %> </td> <tr> <% end %> </table>
<br />
<%= link_to "New Comment", new_post_comment_path(@post)%> <%= link_to "Back to Post", @post%> </code>
I've seen in other forums that at least two other people had the same error, but no resolution.
Thanks to anyone who can help point me in the right direction!
Oh and if you need it, here is my comments_controller.rb <code> class CommentsController < ApplicationController def index @post = Post.find(params[:post_id]) @comments = @post.comments end
def show @post = Post.find(params[:post_id]) @comment = @post.comments end
def new @post = Post.find(params[:post_id]) @comment = @post.comments.build end
def edit @post = Post.find(params[:post_id]) @comment = @post.comments.find(params[:id]) end
def create @post = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) if @comment.save redirect_to post_comment_url(@post,@comment) else render :action => "new" end end
def update @post = Post.find(params[:post_id]) @comment = Comment.find(params[:id]) if @comment.update_attributes(params[:comment]) redirect_to post_comment_url(@post, @comment) else render :action => "edit" end end
def destroy @post = Post.find(params[:post_id]) @comment = Comment.find(params[:id]) @comment.destroy
respond_to do |format| format.html { redirect_to post_comments_path(@post) } format.xml {head :ok} end end
end </code>