after doing a bunch of reading I have finally sat down to create a
simple app to dirve home a lor of the concepts to which have been read.
So I figured a simple blog app is the best way to do it. The bad
thing is that I am already hung up when creating replies to a blog
posting.
I can''t figure out how to insert the post_id value into the reply
table. When creating a reply the user is directed to a page via a url
simular to the following http://localhost:3000/main/reply/4, with the
value 4 being the post_id that is being replied to.
In the controller I have:
class MainController < ApplicationController
def index
#display a list of the posts
@posts = Post.find(:all, :order => "id desc")
end
def reply
#display the post that is being replied to
@post = Post.find(params[:id])
@reply = Reply.new
end
def post_reply
@reply = Reply.find(params[:id])
redirect_to :index
end
end
-------------------
Here if the form
<h2><%= @post.title %></h2>
<p>
<%= @post.content%>
</p>
<% form_for :reply, :url => {:action => :post_reply} do |form| %>
<label for="content">Reply:</label>
<%= form.text_area :content, :rows => 8, :cols => 50 %>
<%= submit_tag "Submit" %>
<% end %>
----------------
So within the post_reply method in the controller, how do I get that
post_id from the url, or do I have to create a hidden input tag
containing it?
Thanks for the help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---