views:

229

answers:

1

Hi guys,

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 webservice 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>
+1  A: 
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 => "[email protected]", :password => "1234"

This create a remote user with these attributes.

Luke