Need an HTTP gem for rails - ruby-on-rails

I'm not pleased with Net::HTTP at all, and I'm looking for a lightweight gem that will either replace that library or at the very least hide it from me.
Does anyone have any suggestions?

My vote goes to HTTParty. It's incredibly simple to use and can be as powerful as you choose. Here's a code sample:
HTTParty.get("http://maps.googleapis.com/maps/api/distancematrix/json?origins=New+York+NY&destinations=Los+Angeles+CA&mode=car&language=en&sensor=false")
Pretty simple stuff depending on what you're using it for.

Try the RestClient gem:
https://github.com/archiloque/rest-client

There are a few out there.
Ruby toolbox has a http client list: http://ruby-toolbox.com/categories/http_clients.html
Personally I usually use HTTParty... or sometimes Mechanize, it's good for submitting forms
I would recommend checking the docs of each, to see which one suits your purpose best.
Hope this helps.

You might want to check out the rest gem, it was created and tested so we could find the best performing http gems by wrapping those gems and creating a standard interface to them. Turns out HTTParty and RestClient are very slow gems so I wouldn't recommend those, although you can always swap out the underlying gem in rest to see for yourself without having to change your code (other than initialization). rest gem by default will be much, much faster.
It's also very easy to use:
#rest = Rest::Client.new()
#rest.get(url, options...)
More info: https://github.com/iron-io/rest

Related

Consume REST from ruby, is there a good gem for this?

I need to consume resources from a REST api, and I'm trying to find a good gem for doing this, but I can't find anything good...
What do you use for this??
I use the REST Client gem for this - it's worked well so far.
I use Active Resource. (But Active Resource is too short an answer since StackOverflow requires that answers be at least 30 characters.)

Using Photobucket api with Ruby on Rails

I am trying to use Photobucket(API) as a image uploading option in my website.
Is there any available gem to do this? or should i use things like REST to achieve this?
Please suggest.
Thanks,
Balan
The only thing I really found was this https://bitbucket.org/photobucket/api-ruby/src/7b69e473fb9fd5b4d37e2ad7f266500e45ef524b/example.rb?at=default. They are using the oauth rubygem to talk to photobucket, still a lot of manual process involved. It is also still using REST.
I would say the easiest way it going ahead and using REST following http://pic.photobucket.com/dev_help/WebHelpPublic/PhotobucketPublicHelp.htm and http://pic.photobucket.com/dev_help/WebHelpPublic/Content/FAQ/FAQOverview.htm to get you started.
I haven't done a REST client in ruby but this gem looks pretty good https://github.com/rest-client/rest-client.
I would recommend, assuming you have the time, making a photobucket ruby gem and wrapping the REST calls in useful class abstractions. It is great for the community, forces you to follow good practices(to a certain extent) and will provide great experience to put on a resume/talk about in an interview.

How to create SOAP api webserices in rails3.1

I want to know whether it is possible to create SOAP APIs in RAILS. I googled and found that SAVON can be used for communicating with SOAP API, is their anyway to create soap apis in rails 3.
We've just released 0.3.2 of https://github.com/roundlake/wash_out with new tiny features. It's currently active and maintained (unlike ActionWebService). And is probably best way to do what you want.
However even being maintainer of such a gem I do not recommend you to use SOAP at all. WashOut was created for the cases where you have no choice. So please think twice. In most cases REST is much more preferable.
There's a gem called actionwebservice that served this purpose many years ago. There are a few people who have maintained it along the way, but you might have to dig around. Searching ruby gems.org brings up a few results but it seems like even these are not really maintained. You might want to check out some of the forks too and see if they are still being maintained.
Having said that, if you have the option to not use SOAP, don't. Use REST as support for it is built into Rails and likely isn't going away any time soon.
Check this gem - https://github.com/roundlake/wash_out

I want to build a chat room using Rails, should I use juggernaut 2 or cramp?

Originally I planned to use Juggernaut, however, it is not compatible with Rails 3. And new Juggernaut 2 seems to be completely independent from Rails, which is not what I want. Then I found cramp, it looks quite neat, but is still under development. So I am just wondering which framework should I use? Or is there a better one?
Thanks!
You're right that the new Juggernaut is de-coupled from Rails, but that doesn't mean you can't use the two together. Juggernaut comes with a Ruby library. Using Juggernaut solves the long-lived connection problem that Toby was talking about.
Any questions about Juggernaut, ping me a line (I'm the creator).
I have looked at the options for this stuff quite extensively and real-time chat is a bit against the grain of Rails. If you really want to stay inside Rails, then Cramp is probably the best option. I recommend you have a look at this article on Websockets and Rails as well: http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/
Using EventMachine to handle the communication means you are that even though you will still be outside Rails, you are at least in Ruby and can share models and libraries.
I have a Async Rails build on GitHub:
https://github.com/tobyhede/AsyncRails
Which is largely based on:
https://github.com/igrigorik/async-rails
Well - you could also try Socky: https://github.com/socky/socky-server-ruby
It's ruby-based, and uses WebSocket as base with flash fallback to support most devices. Also it's complete ruby-based so give it a try if you want :)

Recommended twitter gem for ruby-on-rails

I've found a couple of different twitter gem (for ruby-on-rails) out there:
http://twitter4r.rubyforge.org/
http://twitter.rubyforge.org/
But I'm wondering if someone can rate them and provide a recommendation of either one or a new one.
Thanks
Use twitter. It's actively maintained.
I've used both twitter4r and twitter (outside of Rails though) and over time seem to have stuck with the latter since I find it easy to use and well documented.
Grackle http://github.com/hayesdavis/grackle is pretty good. It's very clean, actively developed and well documented. It supports both Basic and OAuth authentication.

Resources