Using ruby with thin for live chat functionality - ruby-on-rails

So my goal is to create some sort of simple chat functionality, and after a few days (that's right days) with no conclusive direction to go, I've decided to post it here. Basically all I need is a global chat channel that any user on the site can open up and contribute. I think I should be using long-polling. I'd like to know if this can be accomplished using what I have now for the site: Ruby on Rails framework, with Backbone.js on top, also using thin gem for server junk. The only question on SO close to what I'm trying to accomplish is here, but it is an incredibly vague answer. Keep it simple please, while I am pretty well off in most ruby and javascript stuff, this server side event business is basically brand new to me.

I recomend you to try to use private_pub gem https://github.com/ryanb/private_pub
It's using Faye server, and it's easy to use and pretty fast

Related

Rails and Websocket

So I want to be able to get a live stream of notifications for my users that are using my rails application. I heard that you are able to do this using web sockets but I haven't seen anything about it in rails.
Is there a way to do this in rails or am I able to use something else along side my application such as node.js ?
Okay I started searching for different terms and I was able to find Faye
This tutorial is great for it http://code.tutsplus.com/tutorials/how-to-use-faye-as-a-real-time-push-server-in-rails--net-22600
You can also use something like PubNub http://www.pubnub.com/
They support a good amount of languages/libraries such as AngularJS. Great customer service and documentation. Also many examples such as this one: http://www.pubnub.com/developers/data-streams/twitter-stream

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.

What's the benefit of using Sinatra instead of RoR if I'm only need a DB and an API

I need to build a web service, for a mobile game, to manage the states of multiplayer games. I need a database and an RESTful API to access it. I'm very familiar with Ruby On Rails and was thinking of using that since I can throw together the DB and API pretty quickly. However, since RoR is a framework for building web pages and I'm not actually building any web pages, it naturally seems like the wrong technology to use even though it would work. As such, I'm considering using Ruby on Sinatra, but I've never used it before and I'll have to kill some time learning it. For you Ruby gurus, is there an advantage to using Sinatra or a disadvantage to using RoR for what I'm trying to accomplish?
Thanks so much in advance for your wisdom!
You know Rails, you don't know Sinatra. Personally I prefer the latter for things like building APIs, but there's nothing stopping you from doing it in Rails, and there's nothing intrinsically wrong with it either. Unless you want to see this as a learning opportunity for getting into Sinatra, I'd say stick with Rails. Here's some links that might be useful btw:
Building APIs With Rails
Building a Platform API on Rails
It probably depends on your API. If you need more than just a bunch of routes then you will have to come up with your own solutions (authentication, ...).
If all you need is some RESTfulness without the added weight, Sinatra is great. All you need to know is what happens in what route and you're fine. See the Sinatra Readme which has all the information to get started.

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 :)

Web App that uses Webcam...any Rails plugins/gems?

I;m a developer looking to make an app similar to chat roulette. I'm pretty comfortable with Ruby on Rails as my platform and would like to program it in that.
The downside is I have no idea about how to do anything using webcams.
Is there a plugin or gem for rails that integrates webcams easily?
Some quick browsing brought me to abobes site...but I haven't used it before, and though I dont mind learning new things, I'd like to get this out quickly so I'd rather stick to what I know.
What you do you use for webcams?
You would have to use a third-party plug-in to interface the webcam with the site. Rails takes care of things on the back-end (finding and connecting users) but you would need to use Flash or something similar to connect the web page with the camera.
This question is pretty old, but we've been able to use headshot gem in one of our apps.
https://github.com/diwadm/headshot

Resources