Thank you!
Hi @bodrovis,
Here’s another question from @James_Hibbard:
Scenario 2: I’m planning on building a Rails app from scratch using TDD. I know in advance that the users will have to log in to use the app. I’m using Devise for authentication and the cancancan gem for authorization.
Do you have any tips or resources you can point towards for handling this scenario? (i.e. where to start and the best order to do what)
@bodrovis Have you worked with having to authenticate using a SPA front end and a rails backend?
To be honest, I don’t think there is the best and the worst way. Some developers prefer extreme programming by firstly writing tests and then the actual code, some do quite the opposite. If you are unsure where to start, I’d firstly write the code and then proceed to the tests.
By the way, one the best books I’ve read on testing is Rails 4 Test Prescriptions and if you haven’t seen it, I’d really recommend grabbing one. It provides nice examples and thorough explanations.
@James_Hibbard If you’re just practicing I’d say write your own auth. Devise gets complicated really quickly, and cancancan (or Pundit) can be easily written as well.
e.g. old but relevant railscasts com/episodes/385-authorization-from-scratch-part-1 railscasts com/episodes/386-authorization-from-scratch-part-2 https://github.com/railscasts/385-authorization-from-scratch-part-1 github com/railscasts/386-authorization-from-scratch-part-2
Hi @bodrovis
Do you have any tips or suggestions for those who are new to Rails and working on their first project with authentication?
That’s a nice addition! I believe Sitepoint has a tutorial as well, will update the post as soon as I find the link
UPD: Here it is http://www.sitepoint.com/rails-userpassword-authentication-from-scratch-part-i/
To be honest, I don’t think there is the best and the worst way. Some developers prefer extreme programming by firstly writing tests and then the actual code, some do quite the opposite. If you are unsure where to start, I’d firstly write the code and then proceed to the tests.
By the way, one the best books I’ve read on testing is Rails 4 Test Prescriptions and if you haven’t seen it, I’d really recommend grabbing one. It provides nice examples and thorough explanations.
How would you handle this @bodrovis ?
As Benjamin said previously, it is best to start writing authentication system from scratch. Start with something small, simple. When I firstly began using Rails, I was overwhelmed by the amount of things that were done for me and pretty much got lost. I then proceeded step-by-step to really understand what’s going on. The same might happen when using solution like Devise - you’ll probably have hard times understanding how this works together.
If you insist on using some authentication solution, I’d then recommend sticking to a low-level one like Sorcery. http://www.sitepoint.com/magical-authentication-sorcery/
Good luck!
I am not a huge fan of extreme programming, probably because in my country people are really rushing for the result. This way I constantly have to write or re-write the code really fast; coding the tests prior to it would take lots of time. So I’d probably proceed to tests after some coding is done, when I have some working piece of the application. Still, I don’t say that this is the preferred way.
I did. We used AngularJS to code the front-end. As far as I know there is a book about integrating AngularJS and Rails, but I personally haven’t read it so can’t give any feedback.
That’s a wrap!
Thank you all for joining us in today’s chat on Rails authentication. A very big thanks to @bodrovis especially for coming in and sharing his insight into Rails.
My thanks to everyone, this was a great experience that gave plenty of food to chew on! See you!
This topic is no longer a banner. It will no longer appear at the top of every page.
Thanks guys, that’s mighty helpful.
Thanks Ilya.
This Q&A has wrapped up however I will be leaving it open incase you would like to continue the discussion. Happy chatting!