Posts

Showing posts with the label Rails4

Rails 4, MySQL, and Emoji (Mysql2::Error: Incorrect string value: '\xF0\x9F\x8C\x9D')

Step 1   Change encoding from utf8 to utf8mb4 class ConvertTableToUtf8mb4 < ActiveRecord::Migration   def change     # For the table that will store unicode execute:     execute "ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"     # For each column with unicode content execute:     execute "ALTER TABLE `table_name` CHANGE column_name VARCHAR(226) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"   end end Step 2   Change database.yml according to the changes made. development:   adapter: mysql2   database: database_name   username: username   password: password   encoding: utf8mb4   collation: utf8mb4_unicode_ci

Rails4 , Faster loading with turbolinks

The Ruby on Rails version 4.0.0 has been just released. The team took one and half years for development, Rails 4 comes with some interesting new features such as  Turbolinks, improved caching and thread-saf e. Turbolinks c hanges your Rails application into a single page JavaScript application, that is, it doesn't load new pages but instead replaces the current page with new content from the server. [ This is similar to pjax , but here we dont need to worry about wh ich element on the page to replace, and combi ning the server-side response to add , Th e entire body will be replaced ] Few major points on Turbolinks 1. Less Execution time : - Turbolinks makes following links in your web application faster. Turbolinks  won't allow the browser to recompile the JavaScript and CSS between each page change/loading, it keeps the current page there itself and replaces only the body and the title in the head. Execution time of code depends. The more CSS a...