マイペースなRailsおじさん

Ruby、Ruby on Rails、オブジェクト指向設計を主なテーマとして扱います。だんだん大きくなっていくRuby on Rails製プロダクトのメンテナンス性を損なわない方法を考えたり考えなかったりしている人のブログです。

2021-02-01から1ヶ月間の記事一覧

Use rails application configuration to read credentials instead of reading it directly.

When we use secret values, we can utilize credentials. Explained at below page. Securing Rails Applications — Ruby on Rails Guides For example, to use secret information for omniauth configuration, we can read from credentials. config.omni…

Set placeholder for 'contenteditable' element.

We can add placeholder to contenteditable element. HTML [contenteditable="true"]:empty::before { content: attr(data-placeholder); color: #ccc; } CSS <p contenteditable="true" data-placeholder="Please input something."></p> And then we placeholder appers. Sample https://jsfiddle.net/ytnk531/tgLw1fv5/…

tribute.js supports `contenteditable`

tribute.js is used to implement mention feature. GitHub - zurb/tribute: ES6 Native @mentions By the way, in Slack (and some chat applications) highlights inputted mentions as illustrated below. tribute.js can implement such decoration. I i…

sidekiq does not support local time zone.

sidekiq logger prints messages with occurrence time. This time is UTC. I wanted to use JST. After investigating the source code and github of sideq, I retired to do that. Because I realized sidekiq uses only UTC arbitrarily. In sidekiq log…

`break` terminates smallest loop and overrides return value.

As you know break terminates loop. Below code execute the block only once. And return nil. [1, 2, 3].each { |n| break } # => nil break can have 1 argument. If the argument was given, the value will be used as the return value of evaluation…

Authenticate user by twitter with devise and omniauth

We can authenticate an user with twitter. Set route as below. This activates callback url from twitter. devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } devise_scope :user do get 'sign_in', :to => 'd…