Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Using a single database for multiple users

authentication

  • Please log in to reply
4 replies to this topic

#1 byebyeroom

byebyeroom

    Passenger

  • Members
  • 2 posts

Posted 18 February 2014 - 12:00 AM

Dear all,

 

I have an application developed in Rails 1.2.something (I'm porting it to rails 4 and that is a story in itself, please ignore this for the moment).

 

The application (a Property Management System) has been used until now by a single property accessing it through basic http authentication.

 

Now I want to sell the system to many properties hence the need to use the userid as a foreign key in EVERY table of the application. I'll provide a (simplified) example here:

 

TABLE "Properties"

 

Now:

id

name

 

After:

id

userid

name

 

When I'll write for example "Property.find(:all)" I want the application to find all properties with a certain "userid" (taken from http authentication) set up. When I'll write "Property.save" I want the application to automatically fill in the "userid" field with the userid taken from http authentication again, and so on...

 

The question is: what is the best way to modify an existing application so that EVERY activerecord interaction in the application takes the new field "userid" into account?

 

I other words: I have an application created for a single user, many years ago (2006). What would be the best way to change this application in order to be able to store in the database data for multiple users?

 

Thank you

Best regards

 

Stefano

 



#2 erowlin

erowlin

    Passenger

  • Members
  • 9 posts

Posted 18 February 2014 - 04:37 AM

Devise will do the job for you.

 

https://github.com/p...formatec/devise


  • byebyeroom likes this

#3 byebyeroom

byebyeroom

    Passenger

  • Members
  • 2 posts

Posted 18 February 2014 - 06:15 AM

Thank you. 

 

But ... with Rails = 1.2?!



#4 erowlin

erowlin

    Passenger

  • Members
  • 9 posts

Posted 18 February 2014 - 11:05 AM

Try the 1..0 version, it may work :) https://github.com/p...evise/tree/v1.0



#5 DavidPlant

DavidPlant

    Passenger

  • Members
  • 2 posts

Posted 24 February 2014 - 09:33 AM

 I would like to allow multiple MySQL databases to be accessed by only one user....

 

 

Wholesale Branded Clothing

 

Wholesale Clothing Suppliers




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users