=Example SQL store using ActiveRecord A store is required by an OpenID server and optionally by the consumer to store associations, nonces, and auth key information across requests and threads. This directory contains code useful in implementing an ActiveRecord based store as an alternative to using the standard OpenID::FilesystemStore in Ruby on Rails applications. ==Setting up your database You'll need to add three tables to your databases. There are two different ways to do this outlined below. ===Starting from scratch This directory contains three SQL schema files with the proper SQL for adding the necessary OpenID tables in SQLite, MySQL, and Postgresql. See the schema.type.sql files for more information. ===Upgrading with a rails migration script Rails has built-in database migration functionality. If you are trying to add OpenID support into your existing rails application, then you'll probably want to use the enclosed migration script, XX_add_openidstore.rb. Put this file in rails app's db/migrate directory and replace the XX with the next migration number. If there aren't migrations, the number will be 0. ==The OpenID Models From the models dir, copy openid_association.rb, openid_nonce.rb, and openid_setting.rb into the app/models dir of your rails app. ==The OpenIDStoreHelper You'll probably have controller for handling openid operations in your application (see the other examples). The control flow of the store is handled in a helper. Look at OpenidHelper in openid_helper.rb, which implements the OpenID::Store interface. Copy the openid_helper.rb into your app/helpers and then include the OpenidHelper module in your openid controller. When instantiating your OpenIDServer or OpenIDConsumer instance, you'll simply be able to pass in self as the store. ==Unit testing your ActiveRecord OpenID store The Ruby OpenID library comes with a generic StoreTestCase module that can be mixed into any store test case. Copy openidstore_test.rb into your rails' app test/unit dir. Change the line that contains "include OpenidHelper" to include your openid helper if it has a different name. You may also need to change the require at the top to get at storetestcase.rb. You won't need to change it if you are using the openid library in the vendor directory of your rails' app. ==Questions? Contact Brian Ellin a line at brian at janrain dot com