2012/1/31 Kevin Bedell <kbed...@gmail.com>: > I appreciate what you're trying to do. I've been a dba in the past and > have built apps using database credentials in the past. > > But this is a mistake. They key to being successful with rails is to > leave behind the ways you did things before and embrace 'the rails > way'. > > ActiveRecord using a single connection string to connect to the > database -- it's in the database.yml file in the /config directory. > Having it somehow use different credentials based on the user would > make things much more complicated than need be. > > My advice -- forget about how you did things before and embrace the > powerful and fast tools that rails provides to do things. > > In this case, use 'device' -- it's what almost everyone else uses and > you'll thank yourself later for doing so. If you proceed with the way > you're going then later on you'll kick yourself and wonder what the > hell you were thinking. > > Best of luck. > > On Mon, Jan 30, 2012 at 11:36 AM, Marcin S <msporys...@gmail.com> wrote: >> Hello, Im trying to write a simple app for company internal usage. >> The other applications we use (in php) authenticate users based on >> database credentials, and to be honest I have no idea how to implement >> this. Any suggestions will be great!
I know it's rather bad method, I'll try to convince them to use more standard approach - i think there is also an LDAP service running, and I saw LDAP plugin for 'AuthLogic' (or something like that). Anyway i decided to give a shot to this 'bad method' and this is what i came with (its not pretty). I couldnt use regular establish_connection, bcos it reffering to the application's main connection with database and after posting bad password/username whole app derails, instead i'm talking to postgresql adapter directly. def authenticate(user,password) begin connection = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new(nil, nil, ["hostname", 5432, nil, nil, "dbname", user, password], {}) rescue PGError #FAILED redirect_to root_path return end #SUCCES! connection.disconnect! unless connection.nil? redirect_to orders_path end It's working - but thats all can be said :P I'm not sure if there arn't some leftovers after such call. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.