Rails 4, MySQL, and Emoji (Mysql2::Error: Incorrect string value: '\xF0\x9F\x8C\x9D')
Step 1
Change encoding from utf8 to utf8mb4
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
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
Thanks for sharing this blog post,Nice written skill selenium Online Course Hyderabad
ReplyDelete
ReplyDeleteThis great article has really peaked my interest. I am going to book mark your blog and keep checking for new information about once per week.
Selenium Training in chennai | Selenium Training in anna nagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery