Posts

Showing posts from October, 2016

Pusher with Redux

Image
You might have heard about a wonderful service called Pusher . It is a service which allows you to make live updates without handling infrastructure on your own. When I wanted to add it into my React - Redux application I was surprised to find out that there are no libraries which help you. So I decided to write my own. I called it pusher-redux . I think it turned out to have a very convenient API you can call anywhere from your Redux application. Let me explain how to use it below. First you need to configure Pusher in your app.js: Then you need to subscribe to it in your component: This is how you handle it in your reducer Pusher-redux dispatches actions of the following format, you can find data you send in action.data:

Smart page titles in Ruby on Rails

Image
Having separate titles for each page in Rails application is a very common requirement and yet RoR does not provide any built in ways to deal with it. I am going to present you with some handy code that can solve this problem without use of gems. There are going to be 3 ways to define a page title: For tho whole controller. For a specific action inside a controller. Implicitly from a controller name. Last is gonna be especially useful, you can just drop the following code into your application and have reasonably good titles. So lets add code to our parent ApplicationController: And reference page title in our layout: After that setting pages titles is extremely easy. You don't even have to do it if you are naming your controllers properly.