Our app (before authentication) has Customers and Widgets. As you’d expect each customer has a single record in the Customers table, and we don’t want customers to get into each other’s accounts.
I was able to get devise for rails installed and working fine. (The most helpful tutorials IMO were http://presentations.royvandewater.com/authentication-with-devise.html and http://asciicasts.com/episodes/209-introducing-devise )
our root page on our site (Home#index) simply displays the register or sign-in links.
if user signs in we want to take them to the CustomerSController show method for THEIR account…
so I need to do three things, none of which I see how to do with Devise:
a) when a User registers, and User record is created, also create a
new blank Customer record (I know
how to create a Customer.new, I just
don’t see where to ‘put’ that code)
b) associate that brand new Customer
record with their User
record (1 to 1) — should I put
the customer.id in users or the
other way around?
c) when they sign in, direct them to
customers/[theUser.customer.id]
(or something like that)
a & b)
You have to use after create hook (something like this):
c) And then in registrations controller add this: