title: Laravel 4: RouteNotFoundException with Route::resources
body: <p>I have the following error when try to access to localhost:8000/users after a login success:</p>
  
  <pre><code>    RouteNotFoundException: Unable to generate a URL for the named route "users" as 
      such route does not exist.
  </code></pre>
  
  <p>My controller is:</p>
  
  <pre><code>&lt;?php
  
  class UserController extends BaseController {
  
      //public $restful = TRUE;
  
      public function index()
      {
          return View::make('users.index')
              -&gt;with('title', "Title Example")
              -&gt;with('users', User::all());
      }
  
  
      public function create()
      {
          return View::make('users.new')
              -&gt;with('title', "New User");
      }
  
      ...
  </code></pre>
  
  <p>My routes.php:</p>
  
  <pre><code>Route::resource('users', 'UserController');
  
  Route::get('login', array( 'as' =&gt;'login','uses' =&gt; 'UserController@login'));
  
  Route::post('login', function(){
  
      $credentials = array('email' =&gt; Input::get('email'), 'password' =&gt; Input::get('password'));
  
      if (Auth::attempt($credentials))
      {
           return Redirect::route('users.index');
      }
      else
      {
          return Redirect::back()-&gt;withInput()-&gt;with('login_errors',true);;
      }   
  
  });
  
  Route::get('logout', function(){
  
          Auth::logout();
  
          return Redirect::route('login');
  });
  </code></pre>
  
  <p>Console php artisan routes</p>
  
  <pre><code>GET /                                                   Closure                         
  GET /users                       users.index            UserController@index            
  GET /users/create                users.create           UserController@create           
  POST /users                      users.store            UserController@store            
  GET /users/{users}               users.show             UserController@show             
  GET /users/{users}/edit          users.edit             UserController@edit             
  PUT /users/{users}               users.update           UserController@update           
  PATCH /users/{users}                                    UserController@update           
  DELETE /users/{users}            users.destroy          UserController@destroy          
  GET /login                       login                  UserController@login            
  POST /login                                             Closure                         
  GET /logout                                             Closure   
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>in /Users/sangar1982/Sites/tlaravel4/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php line 134
  at UrlGenerator-&gt;generate('users', array(), true) in /Users/sangar1982/Sites/tlaravel4/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php line 181
  at UrlGenerator-&gt;route('users') in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 4299
  at Facade::__callStatic('route', array('users')) in /Users/sangar1982/Sites/tlaravel4/app/storage/views/5fc6ba4595a2ad28f9c15b73141f869f line 30
  at URL::route('users') in /Users/sangar1982/Sites/tlaravel4/app/storage/views/5fc6ba4595a2ad28f9c15b73141f869f line 30
  at include('/Users/sangar1982/Sites/tlaravel4/app/storage/views/5fc6ba4595a2ad28f9c15b73141f869f') in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15928
  at PhpEngine-&gt;evaluatePath('/Users/sangar1982/Sites/tlaravel4/bootstrap/../app/storage/views/5fc6ba4595a2ad28f9c15b73141f869f', array('__env' =&gt; object(Environment), 'app' =&gt; object(Application), 'errors' =&gt; object(MessageBag), 'title' =&gt; 'Title Example', 'users' =&gt; object(Collection))) in /Users/sangar1982/Sites/tlaravel4/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php line 45
  at CompilerEngine-&gt;get('/Users/sangar1982/Sites/tlaravel4/app/config/../views/layouts/backend.blade.php', array('__env' =&gt; object(Environment), 'app' =&gt; object(Application), 'errors' =&gt; object(MessageBag), 'title' =&gt; 'Title Example', 'users' =&gt; object(Collection))) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15692
  at View-&gt;getContents() in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15675
  at View-&gt;render() in /Users/sangar1982/Sites/tlaravel4/app/storage/views/178250f445fac7ac6adce8b5af153a21 line 8
  at include('/Users/sangar1982/Sites/tlaravel4/app/storage/views/178250f445fac7ac6adce8b5af153a21') in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15928
  at PhpEngine-&gt;evaluatePath('/Users/sangar1982/Sites/tlaravel4/bootstrap/../app/storage/views/178250f445fac7ac6adce8b5af153a21', array('__env' =&gt; object(Environment), 'app' =&gt; object(Application), 'errors' =&gt; object(MessageBag), 'title' =&gt; 'Title Example', 'users' =&gt; object(Collection))) in /Users/sangar1982/Sites/tlaravel4/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php line 45
  at CompilerEngine-&gt;get('/Users/sangar1982/Sites/tlaravel4/app/config/../views/users/index.blade.php', array('__env' =&gt; object(Environment), 'app' =&gt; object(Application), 'errors' =&gt; object(MessageBag), 'title' =&gt; 'Title Example', 'users' =&gt; object(Collection))) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15692
  at View-&gt;getContents() in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 15675
  at View-&gt;render() in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 16983
  at Response-&gt;setContent(object(View)) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 16015
  at Response-&gt;__construct(object(View)) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 7407
  at Router-&gt;prepare(object(View), object(Request)) in /Users/sangar1982/Sites/tlaravel4/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php line 156
  at Controller-&gt;processResponse(object(Router), 'index', object(View)) in /Users/sangar1982/Sites/tlaravel4/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php line 126
  at Controller-&gt;callAction(object(Application), object(Router), 'index', array()) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 7094
  at Router-&gt;Illuminate\Routing\{closure}()
  at call_user_func_array(object(Closure), array()) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 13427
  at Route-&gt;callCallable() in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 13406
  at Route-&gt;run(object(Request)) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 7114
  at Router-&gt;dispatch(object(Request)) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 958
  at Application-&gt;dispatch(object(Request)) in /Users/sangar1982/Sites/tlaravel4/bootstrap/compiled.php line 946
  at Application-&gt;run() in /Users/sangar1982/Sites/tlaravel4/public/index.php line 49
  at require_once('/Users/sangar1982/Sites/tlaravel4/public/index.php') in /Users/sangar1982/Sites/tlaravel4/server.php line 19
  </code></pre>
  
  <p>I´m not able to find what is wrong. It seems all ok.</p>
  
  <p>Can someone help me, please? Thanks!</p>
  
  <p>Updated with exception log</p>