Displaying 6 results from an estimated 6 matches for "prefix_options".
2008 Dec 02
2
ActiveResource - xml and json format return different results
Hi,
I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to
JSON and thought that it will work smoothly, but unfortunately it
wasn''t the case.
XML and JSON formats generate different objects:
XML version
#<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon
Nov 28 11...}>
JSON version
#<User:0xb746af5c @prefix_options={}, @attributes={"user"=>#<User:
0xb746ac64 @prefix_options={}, @attributes={"created_at"=>Mon Nov 28
11...}>
As you can see, when using JSON format,...
2012 Feb 26
0
Getting ArgumentError calling initialize with ActiveResource 3.2.1
instantiate_record calls new, and new implicitly calls initialize
(unless I''m not understanding the mystery)
In base.rb
def instantiate_record(record, prefix_options = {})
new(record, true).tap do |resource|
resource.prefix_options = prefix_options
end
end
As it''s written get an ArgumentError as this calls new(record, true).
If I change the code in base.rb to the following:
def instantiate_record(record, prefix_options = {})
new(record).ta...
2009 Apr 29
1
Different behaviour on ActiveResorce with JSON or XML
...pr 28 14:48:55 UTC 2009,
"url"=>"www.google.com", "id"=>2, "created_at"=>Tue Apr 28 14:48:55
UTC 2009}
]
Nice and smooth.
But when it is JSON:
Content.find(:all)[0,2].map(&:attributes)
=> [
{"content"=>#<Content:0x2040d10 @prefix_options={}, @attributes=
{"updated_at"=>"2009-04-27T15:04:32Z", "url"=>"www.google.com",
"id"=>1, "created_at"=>"2009-04-27T15:04:32Z"}>},
{"content"=>#<Content:0x2040248 @prefix_options={}, @attributes=...
2007 May 14
6
ActiveResource and RESful edit
Hi
I''d like to know how to have ActiveResource generate a URL for the
/teams/1/edit
type of resource.
I''ve got custom_methods.rb and have used
Team.find(1).get(:edit)
This generates
http://localhost:xxxx/teams/1/edit.xml
But all I get returned is a hash of the attributes (in this case of
team 1), rather than an object of team 1.
In other words the
2007 Jan 05
0
ActiveResource cache using memcache-client
...escription
def destroy
self.cache_delete
super
end
# See ActiveResource::Base.reload for method description
def reload
self.cache_delete
# This is lifted from ActiveResource::Base.reload and modified
# to pass along the grant argument.
self.load self.class.find(id, @prefix_options).attributes
end
# See ActiveResource::Base.reload for method description
def save
super
self.cache_write
end
def self.build_cache_key(id)
"#{name}:#{id}"
end
def self.cache_read(id)
@@cache.get(self.build_cache_key(id)) if @@cache
end
def self.cache_d...
2010 Dec 31
9
Headers in ActiveResource
I am creating a rails app that is a gui wraping a restful web service
that uses a websso for authentication. This websso sets a series of
headers that I need to pass from the request to the
ActiveResource.find methods. As this is stuff like username etc it is
going to be different for each request. I can find examples on how to
set headers for all requests not just one.
Does anyone know of a way