Devise Facebook Omniauth login with connect and disconnect functionality

When talking about users authentication in Rails land there is one name that generally stands above all the other available gems. This name is Devise.

I would not be so wrong to call it the de facto standard of Rails authentication considering the time has been around and the vast documentation it has under its belt.

Regarding for example the OAuth2 functionality there is a well documented page inside the wiki that describes how to implement it for Facebook.

Unfortunately what presented inside the documentation doesn’t always blend well with the other functionalities of an application.

Continue reading “Devise Facebook Omniauth login with connect and disconnect functionality”

Previewing email in Rails with ActionMailer::Preview and Letter Opener

Developing email templates to be sent by our Rails application may sometimes be a long and tedious operation because under development you must continuously send to yourself the email in order to test the changes.

If you don’t want to waste your time, Rails provides a very helpful tool for those who need to build the layout for the emails of our application: ActionMailer::Preview. In fact, with this tool (available from Rails 4.1), you are able to generate the Rails mailer view without the need to actually send the email.
Continue reading “Previewing email in Rails with ActionMailer::Preview and Letter Opener”

How to share Rails i18n messages with React through webpack

This time I’m here for sharing a solution for a specific problem I encountered a couple of days ago.

There’s this existing Rails monolithic application. Team and customer decided that time had come for this app to be decoupled in two components: Rails would do its usual work as an administration and API backend, while React would be used for the frontend component. Everything related to the frontend would then be rewritten, keeping the same behaviour and visual design. But there are a lot of translations related to the user experience and that have now to be included in the javascript bundle, while they were before used by the server.
Continue reading “How to share Rails i18n messages with React through webpack”