views:

1191

answers:

4

I was following along with the railscast regarding the restful_authentication plugin.

He recommended running the command:

script/generate authenticated user session

Which I did, and everything generated "fine", but then sessions wouldn't work. Checking the site again, he mentions a naming standard and listed updated code which stated:

script/generate authenticated user sessions

With sessions being pluralized.

So now I have session_controller.rb with a SessionController in it, but I guess by naming standards, it is looking for SessionsController, causing the code to fail out with the error "NameError in SessionsController#create "

I see the problem, which is pretty obvious, but what I don't know is, how do I fix this without regenerating the content? Is there a way to reverse the generation process to clear out all changes made by the generation?

I tried just renaming the files to sessions_controller with e SessionsController class, but that failed.

While writing this, I solved my own problem. I had to rename session to sessions in the routes file as a map.resource and rename the view directory from session to sessions, and update session_path in the html.erb file to sessions_path.

So I solved my problem, but my answer regarding removing generated content still remains. Is it possible to ungenerate content?

+1  A: 

You can just roll back to the previous revision in subversion, and start again, right? right? :-)

rails has script/destroy for 'ungenerating' stuff, but I suspect that will only work for the stuff rails ships with, not the restful authentication plugin.

I'd say your best bet is find-in-files (or grep -R if you're not using an IDE) - find everything that refers to your old SessionController and change it

Orion Edwards
+1  A: 

I've never tried script/destroy, but if you're reverting changes that you just made, the generate command should give you a list of files added and changes made. If you're using a version control system of some sort, running status/diff might help as well.

Misplaced
A: 

Thanks for the answers. Sorry for the late accept. I had to leave right after I asked the question.

scubabbl
+10  A: 

Actually, script/destroy works for any generator - generators work by reading a script of sorts on what files to create; script/destroy just reads that script in reverse and removes all the files created, as long as you give it the same arguments you passed to script/generate.

To sum up: script/destroy authenticated user session would have removed all the generated files for you, after which you could have run script/generate user sessions without a problem.

Ben Scofield