Ruby on Rails & other tech

Wikidata queries

Let’s play with Wikidata (query.wikidata.org) Return 20 items which are instance of human which have a twitter account: SELECT ?item ?twitter WHERE { ?item wdt:P31 wd:Q5 . ?item wdt:P2002 ?twitter . } LIMIT 20 Or all Nobel Peace laureates:

redirect_back in Rails 5

redirect_back in Rails 5 is handy: redirect_back(fallback_location: whatever_path) fallback_location is used when HTTP_REFERER is not present. In Rails 4 we had to use redirect_to :back and rescue RedirectBackError: class MyController < ApplicationController rescue_from ActionController::RedirectBackError, with: :redirect_to_default def action redirect_to :back end… Read More ›

Rails 5 tutorial: How to create a Chat with Action Cable

David Heinemeier Hansson recorded a screencast building a chat with Action Cable in Rails 5. Here we have a summary: # app/controllers/rooms_controller.rb # app/views/rooms/show.html.erb # app/view/messages/_message.html.erb rails g channel room speak # app/channels/room_channel.rb And on app/assets/javascripts/cable.coffee we add: # app/assets/javascripts/channels/room.coffee… Read More ›