Jason Clark
unread,Jun 29, 2011, 1:12:11 PM6/29/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
All -
Don't you love it when someone prefaces their discussion with being
new to Rails?
I have a common user type for my application, and recently added a
second model for a different type of user - different rights,
different tools, etc. I'd like to keep the two models separate - and
wasn't convinced that STI was right for my situation. Therefore...
I'd like to keep the user types separate, but was hoping to share the
sessions controller. Is there a way to modify the session controller
below to allow for two types of users to access it. I started by
making a completely separate sessions controller for the other user
type (let's say user2) - but it certainly doesn't seem DRY.
Should I try to edit the controller below? Use STI or Polymorphic?
Other? Help.
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
sign_in user
redirect_back_or user
end
end
def destroy
sign_out
redirect_to root_path
end
end