Laravel 4 Redirect::action() "Route not defined"

laravel-4, php

Solution

Laravel is telling that you have to define a route to use `Route::action()`, something like:

Route::get('forum/bySlug/{slug}', 'ForumTopicController@findBySlug');

Because it will actually build an url and consumme it:

http://your-box/forum/bySlug/{slug}

For that it must find a route pointing to your action.

Problem

I'm currently having troubles with Laravel 4. I would like to use slugs for forum categories and forum topics (slugs are unique). In order to determinate if the user is in a category or in a topic, I have this route: ``` Route::get('forum/{slug}', function($slug) { $category = ForumCategory::where('slug', '=', $slug)->first(); if (!is_null($category)) return Redirect::action('ForumCategoryController@findBySlug', array('slug' => $slug)); else { $topic = ForumTopic::where('slug', '=', $slug)->first(); if (!is_null($topic)) return Redirect::action('ForumTopicController@findBySlug', array('slug' => $slug)); else return 'fail'; } }); ``` And I have the following error when I try to reach a category: `Route [ForumCategoryController@findBySlug] not defined.` Here is my ForumCategoryController: ``` class ForumCategoryController extends BaseController { public function findBySlug($slug) { $category = ForumCategory::where('slug', '=', $slug)->first(); return View::make('forum.category', array( 'title' => 'Catégorie', 'category' => $category )); } } ``` Where is the problem ? Is there a way to do it better ? Help please :)

Original source