how to make two services share a Devise authentication system? - ruby-on-rails

I have had a Rails app which authenticate users with Devise. It works well.
And my next task is to build a real-time chat room. Rails doesn't fit it, so I want to implement it on EventMachine.
But how to integrate the working devise authentication system into chat room? For example, in Rails I can get current user by simple:
current_user
How to implement it in another separate service(EM chat room in my case)? Of course, the backend of chat room can access Rails' database.

Why do you say "Rails doesn't fit it"? Try to keep it all under one roof. As #Bob mentioned, there are some tools that will do just that.
http://railscasts.com/episodes/316-private-pub but also
http://railscasts.com/episodes/260-messaging-with-faye
There are other ones as well that will integrate nicely with Rails. Otherwise, the question of EventMachine & Rails integration was asked before: How do EventMachine & Rails integrate?

Related

I want to add a Facebook style messenger to my Ruby on Rails application so Users from the User model can have a conversation with each other

So right now I have a basic CRUD app using Devise. I have a User model I generated with it. I want to know what the best way would be to add a messenger component to it similar to Facebooks so users can talk with each other. What would if possible be the best way to accomplish this within Rails?
You can probably easily take advantage of Action Cable, to use existing Rails WebSocket functionality and get it good enough.
If you really want to make it like Facebook, you will need to use MQTT. I have no experience with it, but https://github.com/njh/ruby-mqtt purports to be a pure Ruby gem that implements the MQTT protocol.

Adding Email to my Rails app

I currently Have an application that can sign up a subscriber. Everything is pretty basic at this point. The people I'm creating this app for would like the ability to send custom emails to everybody that is subscribed. I'm new to web development and I'm not sure what the capabilities of rails are and I'm not sure what the best way to handle this request is? My first thought is to try and integrate with the mailchimp api and when a user subscribes it automatically fills their email and name in the mailchimp list. So, now the owners of the app can send custom email through mailchimp. My question is - What is the best way to implement this feature in my rails app. What services are available and what tutorials will help me set it up? Any help would be great Thank You!
The pragmatic studio has a decent tutorial on how to set up ActionMailer. I would recommend watching it and then moving on to third-party tools for production.
How to Create, Preview, and Send email from your Rails app
Here is the gem I used to send emails from my rails app. https://github.com/mikel/mail . This gem has good documentation and I am sure you can handle your requirements using this.

Ruby on rails SaaS application where to begin, what tools to use

I'm at the point in my application where I would like to integrate a saas solution into my application using ruby on rails. So far everything has been good except I am unsure where to begin.
My Idea:
I would create a subscription.rb and plan.rb model. A user would belong to subscription and subscription would have many users. Next subscriptions would have many plans and plans would belong to subscription. I would then add role for each plan to limit a user from certain parts of the application maybe using cancan. After setting everything up I would integrate stripe into my application to handle the payment side of things.
The above is how I am thinking of setting this up. It may truly be the wrong concept but that is why I wrote it so you could get an understanding of what I am thinking. I know I could use third party services like recurly, chargify, etc but I am opening my eyes to see if this can be done using a similar a approach.
What technologies have you used or prefer to use when creating a saas application?
Is my approach wrong? If so what is a better way to approach this?
Any tips or advice for creating a saas application such as technologies, ruby on rails tools etc.
Take a look at the open source example application for a Rails Membership/Subscription/SaaS Site from the RailsApps project. It comes with a tutorial that explains the implementation in great detail. Here's the libraries it uses:
Devise for authentication
CanCan for authorization
Stripe for recurring billing
Twitter Bootstrap for front-end CSS
Using Stripe for billing makes implementation easy and reduces security risks as Stripe handles all the automated recurring billing.
The RailsApps example puts CanCan together with Rolify and uses roles that correspond with subscription plans to manage user access. It shows how to simplify the architecture so there's no need for the complexity of a subscription.rb or plan.rb model (though you could refactor that if you wanted to).
1) I use MongoDB as the db backend for the flexibility, RSpec for TDD, HAML/SASS, and RailsAdmin for a quick admin dashboard.
2) Its not necessarily wrong, but its up to you in terms of what you plan on allowing users to do.
3) So wait, have you already developed your tool or are you asking us to plan your tool. Also, what kind of Saas application did you intend to build?

How to implement omniauth, healthgraph and rails?

I'm trying to build a very simple Rails app where people can log in and then see a list of their Run Keeper Fitness Activities
I opted to use Devise and OmniAuth to handle the logins (complete with omniauth-runkeeper). All was working well, having followed Ryan Bates brilliant Railscast on the topic.
I was then keen to use the HealthGraph gem to connect to the RunKeeper API. To do so, it needs an access token. I opted to pull this at point of authorising the app, and record it in the user model (as outlined in this Gist) but I'm not sure this approach is quite right. Should I be recording this access token permanently in the database? I can easily create a new connection through the API now by using the following, but I'm concerned that this isn't the securest approach.
#user = HealthGraph::User.new(current_user.run_token)
Any advice or tips on a different approach would be greatly appreciated.
Ian

Multi user/site rails app

I need to create a web app where people will sign up, call it main-app.com, when they sign up my code will generate a usersite.my-app.com, they will login and only be able to manage their mini site. My question is, is it correct to model this out by creating a table for site, a table for user, users belong to site and site has many users. Then I should create a content table that belongs to user AND site?
Is that right?
I am working on this for one of my apps at the moment using the Devise authentication plugin.
To get the central user environment, I was simply going to shard the database using Octopus, Connection_ninja. All are on Github
It's a starting point but not the full solution I'm afraid as I haven't got there myself yet. There are going to be issues to consider such as determining authorization of app specific resources based on which site the user has registered.
Alternatively, The latest edition of Ruby Weekly links to an interesting article on a Ruby implimentation of the Central Authentication Service protocol. It will be worth a read - http://blog.econify.com/2010/12/introducing-classycas.html
Hope this helps a bit...

Resources