# Newbie Qs - Authentication Plugin that supports Instances? Also, Rails 2.3 or 3 for Beginners?

**URL:** <https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076>\
**Category:** Rails\
**Created:** [August 29, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076 "2010-08-29T22:19:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [August 29, 2010, 10:19pm UTC](https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076/1 "2010-08-29T22:19:39Z")

</div>

Hello, this is my first week with Rails.

I’m working to create an app that has Users associated to instances by  
their email address. For example, like Yammer, those with the email  
domain “[yahoo.com](http://yahoo.com)” only see what others with the same domain see…  
Also like Basecamp where you only see your stuff but it all lives in  
the DB.

Is there an authentication plug-in that supports that? ie

1. Registration that is email based (no usernames)
2. Users are assigned to an instance based on their email domain, and  
only see data that is associated to their instance.

Lastly, as I’m new should I start with Rails 3 or stick with Rails  
2.3? From what I can tell  
Pro of Rails 3: I can learn fresh from the start  
Con of Rails 3: Plugins are all for Rails 2+

Thanks for any thoughts or pointers on the above.

B

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [August 29, 2010, 11:25pm UTC](https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076/2 "2010-08-29T23:25:12Z")

</div>

On 29 Aug 2010, at 21:37, nobosh wrote:

> Is there an authentication plug-in that supports that? ie
> 
> 1. Registration that is email based (no usernames)

If it isn’t the default, it’s certainly an option in the most popular  
authentication plugins out there: AuthLogic and Devise. Which one to  
choose depends on how you feel sessions should be managed and what API  
you prefer.

Personally, I think the Rack environment is a good place to maintain  
sessions, especially if you might use other Rack-based apps that need  
to tie into an authenticated session. That’s why I use Devise.

Authlogic feels that a session is in fact a model, much similar to  
other models in Rails. It’s certainly a very nice gem, with lots of  
features and very reliable.

> 1. Users are assigned to an instance based on their email domain, and  
> only see data that is associated to their instance.

That’s your job, you just make the necessary model relationships to  
handle it.

> Lastly, as I’m new should I start with Rails 3 or stick with Rails  
> 2.3? From what I can tell  
> Pro of Rails 3: I can learn fresh from the start  
> Con of Rails 3: Plugins are all for Rails 2+

Don’t let plugins hold you back, most of the ones you’ll need either  
have a rails 3 compatible version available or at least a branch on  
github that supports Rails 3. That includes the two authentication  
gems I talked about a bit earlier.

Quite a lot of syntax and features in Rails 3 are quite different from  
Rails 2 though, so you’ll be limited to some specific blog posts and  
the RoR docs themselves.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [August 30, 2010, 12:17am UTC](https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076/3 "2010-08-30T00:17:18Z")

</div>

@Peter, thanks for the reply, very helpful.

#1 - I’m going to go with Devise, I found a railscasts video that  
should make installing it easy  
#2 - I’ll go with Rails 3, might as well learn the new stuff  
#3 - Regarding “That’s your job, you just make the necessary model  
relationships to  
handle it.” That makes sense, thanks for pointing that out. If you can  
give any tips to point me in the right direction. Example, where would  
a Rails developer add the logic to extract the email domain, create a  
table to store all the domains along with IDs, and then check against  
that whenever a new registration takes place.

Also, in terms of making sure users of Domain A only see Domain A  
content, I’m guessing all my models will need to have the instanceID  
added? thxs

B

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [August 30, 2010, 1:37am UTC](https://www.ruby-forum.com/t/newbie-qs-authentication-plugin-that-supports-instances-also-rails-2-3-or-3-for-beginners/194076/4 "2010-08-30T01:37:33Z")

</div>

nobosh wrote:

> @Peter, thanks for the reply, very helpful.
> 
> #1 - I’m going to go with Devise, I found a railscasts video that  
> should make installing it easy

Devise is great. Clearance works well also, though it has fewer options.  
Clearance is email based by default, you would have to add user name  
support on your own if you wanted.

> Also, in terms of making sure users of Domain A only see Domain A  
> content, I’m guessing all my models will need to have the instanceID  
> added? thxs
> 
> B

You’re making it more complicated than it really is.

class Domain  
has\_many :users  
end

class User  
belongs\_to :domain  
end

Then just check against the current user’s domain.
