I've got the following code
u = Client.get(:show_by_u开发者_StackOverflow社区sername, :username => username.downcase)
When a valid user is returned, they seem to be getting returned as a hash instead of an object that I can call methods on
e.g. I have to access values like
u['id']
instead of
u.id
How can I get it to return it as an object?
Thanks
As described in the docs for the ActiveResource 'get' method, it does not convert them into ActiveResource::Base instances. As it says, you need to use the find
method instead:
u = Client.find(:all, :from => :show_by_username, :params => { :username => username.downcase })
精彩评论