ruby All(most all) you need to know about Ruby 2.7 Ruby 2.7 is released. This post discusses the features that are part of Ruby 2.7 and how you can use them. It also discusses how you can start using Ruby 2.7 in your projects.
rails Cross domain session sharing in Rails - Part 2 We have multiple micro services at Memory.ai which talk to each other and share data. As we are extracting more and more micro services, we were facing the problem of adding authentication layer in every service. In an ideal world, only one service would perform the authentication and other
rails Cross domain session sharing in Rails - Part 1 We have multiple micro services at Memory.ai which talk to each other and share data. As we are extracting more and more micro services, we were facing the problem of adding authentication layer in every service. In an ideal world, only one service would perform the authentication and other
rails prepend_before_action in Rails Rails encourages usage of callbacks in controllers to execute common pieces of  code before or after an action. A very simple example of this is calling the authenticate_user! method from Devise before every action to make sure that user is authenticated. class ApplicationController < ActionController::Base before_action :authenticate_
rails Mastering Packs in Webpacker In the previous article, we saw what Webpacker is and how Rails 6 has integrated it. In this article, we will understand how to use the packs. A new Rails 6 app creates following files under app/javascript, the new destination for writing our JavaScript code. Projects/scratch/better_hn
rubocop Making friends with RuboCop At Memory.ai, we started using RuboCop heavily. This is a story of how we integrated RuboCop into our existing app. This is not an introductory post to RuboCop. Check out what RuboCop is before diving into our experience report.We started with rubocop, rubocop-performance, rubocop-rails and rubocop-rspec gems. We
rails DNS rebinding attacks protection in Rails 6 It is common practice to run a Rails app using a custom domain locally. app.lvh.me is very common. We also use ngrok.io sometimes to interact with third party services. If you are using a custom domain on a Rails 6 app, you will see an error with
rails Understanding Webpacker in Rails 6 Starting with Rails 6, Webpacker is the default JavaScript compiler. It means that all the JavaScript code will be handled by Webpacker instead of the old assets pipeline aka Sprockets. Webpacker is different from asset pipeline in terms of philosophy as well as implementation. In this blog post, we will
rails New framework defaults in Rails 6 Rails 6 is released. This post is part of the Road to Rails 6 series which will prepare you for Rails 6. Every time a new major Rails version is released, there are tons of breaking changes. Upgrading existing app to the new version can be sure shot recipe for
rails Advanced multi-db techniques in Rails 6 Rails 6 is just around the corner. The release candidate two was recently released. This post is part of the Road to Rails 6 series which will prepare you for Rails 6. Check the part one of this post where we saw how to setup an app with multiple databases
rails Setting up Rails 6 app with multiple databases on Heroku Rails 6 is just around the corner. The release candidate two was recently released. This post is part of the Road to Rails 6 series which will prepare you for Rails 6. When we create a new brand new Rails 6 app, it is configured to use only one database.
rails How to (not) use unscoped in Rails Active Record provides unscoped to remove all the scopes added to a model previously. class Article default_scope { where(published: true) } end Article.all # SELECT * FROM articles WHERE published = true Article.unscoped # SELECT * FROM articlesLet's say I want to fetch all articles of an author, published or otherwise. author = Author.
rails Installing capybara-webkit gem on Ubuntu 16.04 I was not able to install capybara-webkit gem on Ubuntu 16.04. I tried to follow the instructions mentioned in the gem wiki to solve this problem. sudo apt-get update sudo apt-get install g++ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-xThen it gave an error saying that the package
emacs Creating pull requests from emacs Learn how to create pull requests in Github from emacs with the help of magit
ruby b - a hidden method from Ruby string class After my last post on how Ruby initializes objects, Sagar shared with me following code. class Abc attr_accessor :a, :b def self.new(a, b) @a = a @b = b end end o = Abc.new("a", "b") puts o.a puts o.b >> o.a => NoMethodError >
ruby Understanding how Ruby initializes objects Deep buried in Rails source code, there is a code snippet: class DeprecationProxy def self.new(*args, &block) object = args.first return object unless object super end ... end It was added 9 years ago and the commit message said: Override new on proxy objects so that they never wrap
community Insights from the SICP meetup We organized a SICP reading meetup on 11th May in Pune. Our inspiration was similar meetup from our friends Siddharth and Soham in Mumbai. This was the second such meetup that we did. The first one was organized in April. When we started this meetup, we didn’t know what
postgresql Fix weird PostgreSQL error after updating Postgres.app Recently I updated Postgres.app and after that I started getting a weird error while running Active Record tests locally using PostgreSQL adapter. /Users/prathamesh/Projects/sources/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `initialize': could not connect to server: No such file or directory
ruby Installing eventmachine gem on El Capitan I keep forgetting how to install eventmachine on El Capitan Mac OS X. So adding this post to lookup when required. $ gem install eventmachine -v '1.0.8' -- --with-cppflags=-I/usr/local/opt/openssl/include More details can be found here and here
emacs Log notes while stopping Org timer Recently I started tracking the time I spent on various coding activities using Org mode. C-c C-x C-i is used to start the timer and C-c C-x C-o is used to stop the timer. I like to add some details about where the time was spent when the timer is
emacs Configuring web-mode with JSX I use web-mode for editing different templates like html, .erb, .js.jsx. It understands React’s JSX tags also which is great because I don’t need a separate mode just for JSX. Web mode can support plain jsx or js.jsx by using auto-mode-alistfunction. (require 'web-mode) (add-to-list 'auto-mode-alist '(
ruby kgio, raindrops, unicorn and Ruby 2.2.0-preview1 I was trying to upgrade Codetriage to use Ruby 2.2.0-preview, the latest Ruby version. The project is hosted on Heroku. So to upgrade I changed Ruby version in Gemfile: # Gemfile ruby '2.2.0' After that I tried to do bundle install: bundle install And boom. Got error:
ruby After effects of updating openssl on Mac OS X Today, my openssl library on Mac OS X Mavericks got updated. After the update, when i tried doing rails s on one of the rails apps, it gave following error: /Users/prathamesh/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta1/lib/rails/
ruby Setting up Ruby development setup with rbenv I wanted to setup ruby source code on my machine. The source on Github has detailed instructions on how to do the setup. git clone github.com/ruby/ruby cd ruby autoconf ./configure make make install worked correctly on Mac OS X and Ruby was installed in usr/local/bin.