1
我正在寻找一个解决方案,以便重用使用Authlogic的另一个Web应用程序的用户表。与Authlogic的共享用户表
我想用ActiveResource(在新的应用程序),但我失去了一些东西。这是不工作代码:
#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
这个练习的真正目的是要建立一个web服务只与Authlogic的用户表。这个Web服务应该从许多应用程序中使用。
任何人有任何提示?
编辑
是的,对不起,这是我认为的错误:
NoMethodError in Users#new
Showing app/views/users/_form.html.erb where line #5 raised:
undefined method `username' for #<User:0x103477bc0>
有什么不合作呢?你有什么错误吗? –
ActiveResource定义中缺少element_name声明会成为问题吗? http://api.rubyonrails.org/classes/ActiveResource/Base.html – tadman
它不应该是因为我不需要self.element_name =“user”,因为模型具有相同的名称。 – Irukandji