Search Results

Search found 1 results on 1 pages for 'ntaj'.

Page 1/1 | 1 

  • Michael Hartl's rails tutorial: reusing sessions resource for multiple User types

    - by ntaj
    I'm learning Ruby on Rails through Micheal Hartl's tutorial. In my web application, I require two types of Users, called publishers and subscribers. Currently I have a publishers resource and a subscribers resource. I'd like both of them to be able to use the sessions resource for signin/signout. I'm looking for some direction on how to implement this. Should my publisher and subscriber resource inherit from the User resource, so that, for example, the following code works through polymorphism? def create user = User.find_by_email(params[:session][:email]) if user && user.authenticate(params[:session][:password]) # Sign the user in and redirect to the user's show page. else # Create an error message and re-render the signin form. end end The publisher and subscriber do not have many common fields and different capabilities, so I think they should be modeled as two separate resources, but how to have them share the Sessions resource?

    Read the article

1