On Apr 20, 10:40 am, Neil Bye <[email protected]> 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 @comment is what the user
> > wants to comment on) rather than user_subcomments_path(@user) with a
> > hidden field with the comment_id because the user creating an object is
> > usually obtainable via your login system (indeed in most cases you don't
> > want people to be able to create subcomments as other users just by
> > editing the URL the form posts to)
>
> Ok I see your point but now I run into a routes problem which doesn't
> come up if I use user_subcomments_path(@user)
>
> When I use 'comment_subcomments_path(@comment)' I get 'No route matches
> {:controller=>"subcomments"}'
>

have you tried form_for [@comment, :subcomment] ?
This will make sure that the http method etc is right for creating a
new comment

Fred


> Of course subcomments_controller exists
>
> This is from routes.rb
>
> resources :comments
> resources :subcomments
> resources :users
>
> resources :users   do
>
>         resources :comments
>   end
>
>   resources :comments   do
>
>         resources :subcomments
>   end
>
>   resources :users   do
>
>         resources :subcomments
>   end
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to