ITERATION F1: ADDING USERS
Anders Nehlin
12 posts
|
Hi, Thanks in advance for your help! Best regards, |
Sam Ruby
196 posts
|
Unfortunately, you have gone past the point where the material has been updated for Rails 2.0. Check the “Preface to the Third Edition” on page 15 for details. The color of the bars on the top and bottom of the page also provide a visual clue. Chapter 11 will be updated in the next beta, which should be out in under a week. |
Anders Nehlin
12 posts
|
Thanks for your response. I have to wait until then I guess. |
osagie uwaifo
8 posts
|
Anders try restarting your application. If that does not work, create a dummy controller like the way the store controller was created. Access the dummy controller, then access the login controller. That should work. That is what i did. |
Anders Nehlin
12 posts
|
Hi osagie, Thanks for your help! |
Anders Nehlin
12 posts
|
Hi guys, I have used the downloaded files in chapter 11 of the latest version (28 May) but I still got the same error message. It is very frustrating to be stuck and depending on your help since I am a newbie…. Appreciate all help. Thanks in advance! |
Sam Ruby
196 posts
|
I understand and appreciate your frustration. We simply are going to have to debug this together, and since I can’t actually see your machine, that will by necessity be a slow process. But rest assured that I’m not going anywhere, and intend to see this through. But first we have to back up. You say that you downloaded the files and are seeing the same error message. One of those can’t be true. How do I know that? The error message references an add_user method. There is no add_user method defined in the 28 May version of the book. This method is purportedly in the login controller. Once again, there is no login controller in the 28 May version of the book. The user add functionality has been replaced by the What I need you to do here is to back out the work that you did based on prior betas, and to pick up once again with the start of chapter 11 and try to reproduce the results. If you leave comments as to your progress, I will check back and try to make helpful suggestions. How does that sound? |
Anders Nehlin
12 posts
|
Sounds fine with me!! Thanks a lot. |
Donald Craig
2 posts
|
I think that the problem may be on page 165 of B1.2, where it says to visit the URL: http://localhost:3000/login/add_user I believe that it should be: http://localhost:3000/users/new (The figure on the same page is outdated too.) |
Anders Nehlin
12 posts
|
Hi guys, Now I have messed up my store by trying to replace files from the code-folder. When I browse to http://localhost:3000/store it goes to http://localhost:3000/admin/login instead. And when I go to http://localhost:3000/login/add_user I got the following error message: Still stuck but hopeful.. |
Sam Ruby
196 posts
|
Donald: you are correct, and I will fix that (both the text and the image) in the next beta. Anders: it actually sounds like you are not messed up. /store should redirect to /admin/login and /login/add_user should be a routing error. With B1.2, the intended way to create a new user is with /users/new. |
Anders Nehlin
12 posts
|
Hi Sam, When I try to create a new user at http://localhost:3000/users/new it redirects to http://localhost:3000/admin/login, so I can’t register myself. What shall I do? How do I get access to my store again? |
James West
52 posts
|
I am having the same problem. After adding the changes to the application model I am redirected to the login page whenever I try to access anything other than the catalogue. I know this is the expected behaviour and I have set up a user called test but whenever I enter the user into the login screen and press login I just get the login screen re-displayed with no indication as to why so it looks like the redirect is failing. I took my code to the next stage and added the “friendlier log in” stuff but to no avail. The strange thing is that if I comment out the before_filter code in the application.rb the login works and I am directed to the admin page with the order details. My def authorise in the admin looks like this
Also in the admin controller my login looks like this
And none of the flashes appear anywhere to indicate that I have an incorrect login detail. I know I must be missing something but can’t think what and have been through the admin set up twice now so I am kinda stuck now too and any pointers would be appreciated. |
Sam Ruby
196 posts
|
Anders: skip ahead for a moment to page 174. :-) James: I suspect that the controller isn’t setting session[:user_id]. Can you check the login method in app/controllers/admin_controller.rb ? update The problem is what session[:user_id] is set to. Please change: session[:user_id] = :user.id to: session[:user_id] = user.id |
James West
52 posts
|
Hi thanks Sam. I thought pretty much the same thing which is why I included app/controllers/admin_controller.rb login code in my post. I have checked the book and checked against the code you have on-line and the only real difference is the friendlier login code I have added. But the problem existed before I added this. Really confused :-) |
James West
52 posts
|
Hi, Just reversed the friendlyier login in code back out and it all works now. Sorry. |
Anders Nehlin
12 posts
|
Hi Sam, I have not been working with the depot project for a while because I have been struggling with my wireless internet on my laptop. Anyway, now it works so I can get back to the depot project, BUT now I have another problem: I can not browse to the localhost. Do you know if the software for my wireless internet could interfere in some way? Appreciate your help!! |
Anders Nehlin
12 posts
|
Hi again, I forgot to say that I use ubuntu as the OS. |
Sam Ruby
196 posts
|
If browsing to http://127.0.0.1:3000/ works, I would check your |
David Schwartz
26 posts
|
OK, I’ve got the B1.2 printing and had the same confusion. Using users/new worked (although it’s not nicely formatted as shown in the PDF). Am I free to continue? When will the next rev be available that has been updated for R2.0.2? I guess I’ll go and work on my Mac configuration. David |
Sam Ruby
196 posts
|
Given that we are talking about a book that will be published in print form October-ish and people will be buying in stores next year, my focus is to keep up with the latest Rails. Starting with B1.3, this means Rails 2.1. The two differences that were encountered in the upgrade were in Migration (the names of the migration files changed, and Rails internally keeps track of exactly which migrations have been applied, and not merely the last one) and a minor formatting change in the edit scaffold produced by generate/scaffold. |
David Schwartz
26 posts
|
Meaning that there’s really nothing else we have to worry about? |
Sam Ruby
196 posts
|
I don’t believe so. In developing B1.0, B1.1, and B1.2, I had been testing under both 2.0.2 and rails edge. B1.3 was updated so that the text matched 2.1, but the only substantive changes involved were the ones I mentioned above. |
23 posts, 6 voices
