Kaminari provides easy pagination in a rails app. It’s great to use. We’ll make it better by adding a little function to your controllers to provide useful pagination headers.
The default serialization of error states in Rails might not be what you want for your app. In that case, it’d be worth knowing how to write a custom serialization format for your needs. In my case, I am trying to match the JSON API format for errors. Here’s a potential implementation…
For APIs, it seems more and more data is making its way into the HTTP headers. Recently, whilst adding a
Link header, for paging data, into the HTTP response, I realized that my browser code couldn’t see it. Who was the culprit? CORS, of course.
Rails 4 introduced the pattern of strong parameters at the controller layer. As a best practice, you will explicitly list the parameters that an endpoint should accept in payloads. Arrays are specified just slightly different.
Interactive debugging can sometimes be faster and more effective in helping you code than a
puts statement. It’s easy to get interactive debugging in Ruby or on Rails with the help of a nice gem.
Rails asset pipeline allows you to use erb helpers in your CoffeeScript. You’ll still need to bring get these files into Karma runner. It’s really easy. You just need to get to know your Karma config options.
I recently attended the Mountain West Ruby Conference. It was my first time going. I was pleasantly surprised by the quality of the conference. I would recommend it.
Jumpstart Lab offers a Ruby training. I recently attended. I had a great experience and learned a lot in my first real introduction to Ruby and Ruby on Rails. I would highly recommend the course. Here are a few more details on my experience.
When you setup a new Rails project, you’ll have a single layout file which has a single default
yield block. This will soon be inadequate, and you’ll want another. Here’s how to setup multiple
yield blocks per ERB template.