开发者

Associate new Authlogic Model to existing Models

While playing around with Rails (since I am a newbie开发者_StackOverflow) while reading Agile Rails book I came across an issue using the Gem Authlogic that I don't know how to address.

I have a simple business Model. The tables store the following information: Name, Address, Latitude, and Longitude.

The above approach has been working fine, because using the console I can enter the information and it shows up, where I need it to.

My issue now is that I want to add authentication to it. As in assign those records in the table, to individual accounts. Since Authlogic is an authentication gem, can this be done?

What I am trying to get to here is that, I enter a few records and leave it at that. Few days later, I want to assign those individual rows in the table to an authlogic model so the person to whom the record should belong can authenticate to it and make changes.

Any code samples, blog posts to better help me understand would be great!

Thank You.


Authlogic will create a model called users. Let's say your model is called persons. You add a user_id field to your persons model and link them by association:

class Person belongs_to :user end

class User has_one :person end

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜