Forum: Ruby on Rails ActiveResource: Howto use custom header fields

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fb89d03a8d934fe3de9128a0a0d05af9?d=identicon&s=25 Christian Mayer (Guest)
on 2007-05-02 00:54
(Received via mailing list)
Hi,


I'm using the ActiveResource (beta) gem. I need to change the header
fields for the request.
There is "default_header" in ActiveResource::Connection which is
"Content-type: application/xml". I do not see how to change that.
Could someone give me a hint.



TIA & regards,
     chris
6edd67c92a1dab5eb23fed79f3c18564?d=identicon&s=25 DHH (Guest)
on 2007-05-02 02:29
(Received via mailing list)
> There is "default_header" in ActiveResource::Connection which is
> "Content-type: application/xml". I do not see how to change that.
> Could someone give me a hint.

class Project < ActiveResource::Base
  headers['X-Token'] = 'foo'
end

Adds the X-Token header to all requests.
Fb89d03a8d934fe3de9128a0a0d05af9?d=identicon&s=25 Christian Mayer (Guest)
on 2007-05-02 15:18
(Received via mailing list)
2007/5/2, DHH <david.heinemeier@gmail.com>:

Hello,

> > There is "default_header" in ActiveResource::Connection which is
> > "Content-type: application/xml". I do not see how to change that.
> > Could someone give me a hint.

> class Project < ActiveResource::Base
>   headers['X-Token'] = 'foo'
> end
>
> Adds the X-Token header to all requests.

Thank you for your help. The "headers" methods isn't yet included in
the ActiveResource gem. However, due to your hint, I downloaded at the
SVN sources and it works.

regards,
   chris
6edd67c92a1dab5eb23fed79f3c18564?d=identicon&s=25 DHH (Guest)
on 2007-05-03 00:25
(Received via mailing list)
> Thank you for your help. The "headers" methods isn't yet included in
> the ActiveResource gem. However, due to your hint, I downloaded at the
> SVN sources and it works.

Pushed the latest as beta gems.
This topic is locked and can not be replied to.