php - Laravel4: delete a comment -


i have simple blog post resource , comment nested resource. until can see comments belonging post , create new comment post.

i want give possibility delete specific comment, somehow making mistakes.

this view comments.index comments:

@extends('master')  @section('blog')  @foreach($comments $comment)   <div class="span11 well">     <ul>         <li><strong>body: </strong> {{ $comment->body }} </li>         <li><strong>author: </strong> {{ $comment->author }}</li>     </ul>  {{ form::open(array('method' => 'delete', 'route' => array('posts.comments.destroy', $post_id), $comment->id)) }}  {{ form::submit('delete', array('class' => 'btn btn-danger')) }}  {{ form::close() }}   </div> @endforeach {{ link_to_route('posts.index', 'back post index') }} 

this error running index: parameter "comments" route "posts.comments.destroy" must match "[^/]++" ("" given) generate corresponding url.

this index method inside commentscontroller:

public function index($post_id) {     $comments = post::find($post_id)->comments;     return view::make('comments.index', compact('comments'))->with('post_id', $post_id); } 

and destroy method inside commentscontroller:

public function destroy($post_id, $comment_id) {     $comment = $this->comment->find($comment_id)->delete();      return redirect::route('posts.comments.index', $post_id); } 

someone can tell me please making mistake?

this routes:

route::resource('posts', 'postscontroller'); route::resource('posts.comments', 'commentscontroller'); 

you have put regexp tester on route, check comments parameter.
error message says parameter give laravel isn't good.

if parameter decimal id, use \d+ regexp instead.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -