开发者

Shared user table with Authlogic

I'm looking for a solution in order to reuse the user table of another web application that use Authlogic.

I'm trying with ActiveResource (in the new app), but I'm missing something. This is the not working code:

#Existing app
class User < ActiveRecord::Base
   attr_accessible :username, :email, :password
   acts_as_authentic
end

#New app
class User < ActiveResource::Base
  self.site="http://localhost:3001"
end

The real aim of this exercise is to build a w开发者_运维知识库ebservice with only the Authlogic's user table. This web service should be used from many apps.

Anyone has any tip?

EDIT

Yep, sorry, this is the error in my view:

NoMethodError in Users#new
Showing app/views/users/_form.html.erb where line #5 raised:
undefined method `username' for #<User:0x103477bc0>


undefined method `username' for #<User:0x103477bc0>

You cannot use the method new on ActiveResource resources. Or better, you can instantiate a new User with User.new but creates a local object without remote attributes. Try with:

User.create :email => "mail@email.com", :password => "1234"

This create a remote user with these attributes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜