On 19 Apr 2011, at 23:47, Neil Bye li...@ruby-forum.com wrote:
Frederick Cheung wrote in post #993841:
On Apr 19, 8:39pm, Neil Bye li...@ruby-forum.com wrote:
Tim Shaffer wrote in post #993815:
sounds to me like params[:id] isn't set.
Fred
Not sure what you mean. How would I set
On Apr 20, 10:40 am, Neil Bye li...@ruby-forum.com wrote:
%= form_for :subcomment, :remote = true, :url =
user_subcomments_path(@user) do |form| %
%= form.text_field :body %
p%= submit_tag 'Comment' %/p
% end %
comment_subcomments_path(@comment) (assuming
have you tried form_for [@comment, :subcomment] ?
This will make sure that the http method etc is right for creating a
new comment
Fred
I now have:
%= form_for [@comment, :subcomment], :remote = true, :url =
comment_subcomments_path(@comment) do |form| %
%= form.text_field :body
On Apr 20, 11:44 am, Neil Bye li...@ruby-forum.com wrote:
have you tried form_for [@comment, :subcomment] ?
This will make sure that the http method etc is right for creating a
new comment
Fred
I now have:
%= form_for [@comment, :subcomment], :remote = true, :url =
Frederick Cheung wrote in post #993985:
On Apr 20, 11:44am, Neil Bye li...@ruby-forum.com wrote:
%= form.text_field :body %
% end %
But sill get the No route matches {:controller=subcomments}
Sorry, that was wrong - it should be form_for [@comment,
Subcomment.new], you don't need the
On Apr 20, 12:46 pm, Neil Bye li...@ruby-forum.com wrote:
def create
@comment = Comment.find(params[:id])
@comment.subcomments.create( :comment_id = @comment.id , :body =
params[:subcomment][:body])
render :update do |page|
page.reload
end
end
_comment.html.erb
Frederick Cheung wrote in post #994021:
On Apr 20, 12:46pm, Neil Bye li...@ruby-forum.com wrote:
_comment.html.erb has
, that should be form_for [comment, Subcomment.new] - I had
I got there on that but it still says Couldn't find Comment without an
ID
Neil
--
Posted via
On Apr 20, 2:49 pm, Neil Bye li...@ruby-forum.com wrote:
Frederick Cheung wrote in post #994021: On Apr 20, 12:46pm, Neil Bye
li...@ruby-forum.com wrote:
_comment.html.erb has
, that should be form_for [comment, Subcomment.new] - I had
I got there on that but it still says Couldn't
On Apr 20, 3:33 pm, Neil Bye li...@ruby-forum.com wrote:
Frederick Cheung wrote in post #994032:
Check the parameters you get in your controller - you'll probably need
to use params[:comment_id] rather than params[:id]
Fred
Tried params[:comment_id]
It goes to
Neil Bye wrote in post #994040:
Frederick Cheung wrote in post #994032:
Check the parameters you get in your controller - you'll probably need
to use params[:comment_id] rather than params[:id]
Fred
Tried params[:comment_id]
It goes to /comments/1/subcomments and says:
try {
What does your model look like? Do you have the appropriate has_many and
belongs_to for the subcomments to work?
In general, you shouldn't need to specify comment_id for the child when you
access it via the has_many relationship.
For example:
@comment = Comment.find(params[:id])
new_comment =
Tim Shaffer wrote in post #993815:
What does your model look like? Do you have the appropriate has_many and
belongs_to for the subcomments to work?
In general, you shouldn't need to specify comment_id for the child when
you
access it via the has_many relationship.
@comment =
On Apr 19, 8:39 pm, Neil Bye li...@ruby-forum.com wrote:
Tim Shaffer wrote in post #993815:
Is that correct.
Both of your examples throw up 'Couldn't find Comment without an ID'
sounds to me like params[:id] isn't set.
Fred
Am I missing smething vital
--
Posted
Frederick Cheung wrote in post #993841:
On Apr 19, 8:39pm, Neil Bye li...@ruby-forum.com wrote:
Tim Shaffer wrote in post #993815:
sounds to me like params[:id] isn't set.
Fred
Not sure what you mean. How would I set params[:id] ?
It works if I use params[:user_id] or [:current_user_id]
14 matches
Mail list logo