jimchoi (3) [Avatar] Offline
#1
I'm following along the examples in the book. When I get to 3.3.4, I find that the file appcontrollerssessions_controller.rb does not exist, but appcontrollerssession_controller.rb does.

Do you know why that is?

Thanks!
peterarmstrong (94) [Avatar] Offline
#2
Re: sessions_controller.rb does not exist, but session_controller.rb does
It could be that restful_authentication has evolved [and renamed that class] since I last followed along with the book (about a week or two ago).

I'll look into this; if you hit any other issues because of this please post them here.

Thanks,
Peter
Mhason (2) [Avatar] Offline
#3
Re: sessions_controller.rb does not exist, but session_controller.rb does
I experienced the same issue. I had to add:
map.resource :users, :sessions
to the routes.rb file in order to solve the issues it caused. I figured it was because I am using rails v. 2.0.2.

I am not experienced enough to know what other issues this may cause down the road lol....
peterarmstrong (94) [Avatar] Offline
#4
Re: sessions_controller.rb does not exist, but session_controller.rb does
It's not because of rails 2.0.2, it's because restful_authentication seems to have caught up to the Rails 2 conventions as described at http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done:

"We’ve also instigated a new convention that all resource-based controllers will be plural by default. This allows a single resource to be mapped in multiple contexts and still refer to the same controller."

I just followed along with ch. 3 using Rails 2.0.1 and got session_controller.rb instead of sessions_controller...

I'll update chapter 3; thanks very much!
peterarmstrong (94) [Avatar] Offline
#5
Re: sessions_controller.rb does not exist, but session_controller.rb does
What I'm going to recommend doing is to follow along using a slightly outdated version (from December 12, 2007) of restful_authentication. (I'm recommending this only since the book has already been typeset and it's problematic to change at this point.)

C:peterflexiblerailscodepomodo>ruby scriptplugin install -r 3072 http://svn.techno-weenie.net/projects/plugins/restful_authentication/
...

C:peterflexiblerailscodepomodo>ruby scriptgenerate authenticated user sessions

This way, the code which is generated matches the book. If you use the latest restful_authentication you'll need to fix your route as shown above in this thread.

I've finally learned my lesson now: if you ever document anything about Rails or one of its plugins, always show getting a specific revision, rather than "the latest". Yes, this should be obvious. However, it's easy (for me, anyway) to get careless...

Thanks, and sorry for the confusion...

-Peter
peterarmstrong (94) [Avatar] Offline
#6
Re: sessions_controller.rb does not exist, but session_controller.rb does
(The path above should be C:peterflexiblerailscurrentpomodo if you're following along with the book.)
jimchoi (3) [Avatar] Offline
#7
Re: sessions_controller.rb does not exist, but session_controller.rb does
> C:peterflexiblerailscodepomodo>ruby scriptplugin
> install -r 3072
> http://svn.techno-weenie.net/projects/plugins/restful_
> authentication/

Solves the problem. Thanks!
peterarmstrong (94) [Avatar] Offline
#8
Re: sessions_controller.rb does not exist, but session_controller.rb does
Yeah, I tested by following along with Iteration 3 using the -r 3072, but it's nice to have independent confirmation. Thanks!