OmniAICreator/Qiita-1.07M huggingface dataset:
(Article move) Slack-How to get &quot;channel ID&quot; used for API

# I moved the article 

# [Slack — How to get "channel ID" used for API-Qiita](https://qiita.com/YumaInaura/items/0c4f4adb33eb21032c08) 


# Original by
[(記事移動) Slack — APIに使う「チャンネルID」を取得する方法](https://qiita.com/Yinaura/items/bd28c7b9ef614696fb7e)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | The difference between first / last / begin / end / min / max

## first 

Return the first element. that's all.

     [5,4,3,2,1].first # => 5 

## last 

Return the last element. that's all.

     [5,4,3,2,1].last # => 1 

## begin 

Return the first element in the range. (\* 2) It looks like the first version of Range.

     (5..1).begin # => 5 

Actually, begin is the same as first. You can write either. (\* 1)

     (5..1).first # => 5 

But you can not use begin on ordinary arrays.

     [5,4,3,2,1].begin # => NoMethodError: undefined method `begin' for [5, 4, 3, 2, 1]:Array 

## end 

Return the last element in the range. (\* 2) It looks like last in the Range version.

     (5..1).end # => 1 

In fact, end is the same as last. You can write either. (\* 1)

     (5..1).last # => 1 

However, you can not use end for ordinary arrays.

     [5,4,3,2,1].end # => NoMethodError: undefined method `end' for [5, 4, 3, 2, 1]:Array 

# min 

Returns the smallest element in the array. The order of the elements does not matter.

     [5,4,-3,2,1].min # => -3 

# max 

Returns the largest element in the array. The order of the elements does not matter.

     [5,4,30,2,1].max # => 30 

# Annotation 

- 

\* 1) Strictly speaking, there is a difference between taking and not taking arguments. If you do not pass an argument will be the same behavior.

- 

\* 2) The "first element" of Range is the beginning. It is better to say that the "last element" is the end. Ruby's "scope" is relatively complicated, so please refer to the comments in this article.



# Original by
[Ruby | first / last / begin / end / min / max の違い](https://qiita.com/Yinaura/items/77cc63a335b618fc5e90)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
How to pass environment variables to a shell script for display

Make a shell file

     #!/bin/sh echo $COLOR 

Run a shell at the command line At this time, pass the environment variable of COLOR = green.

     $ COLOR=green sh test.sh 

green is displayed.

     green 

* * *

- I think it has been written in various places, but a note. 


# Original by
[シェルスクリプトに環境変数を渡して表示する方法](https://qiita.com/Yinaura/items/978b8c44cbddae1b8df7)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Rails | Does the model&#39;s validate statement work?

Write in validates (plural form) instead of validate (singular form).

     class Example < ActiveRecord::Base - validate :user_id, presence: true + validates :user_id, presence: true end 

In this case, if: user\_id happens to exist as an accessor, note that no error will occur even if you write in validate (singular form). (Refer comment)

# environment 

- Rails 4.0.13 


# Original by
[Rails | モデルの validate 文が効かない？](https://qiita.com/Yinaura/items/c9e7e0629165ee0032f7)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Does t.timestamp not work with Rails | migration?

Write in timestamps (plural form) instead of timestamp (singular form).

Note that even if you write in singular, you will not get an error.

     class CreateExample < ActiveRecord::Migration def change create_table :example do |t| t.string :requester - t.timestamp + t.timestamps end end end 

Remember, "a plural form because we create two pieces of created _at and updated_ at".

# environment 

- Rails 4.0.13 


# Original by
[Rails | migration で t.timestamp が動かない？](https://qiita.com/Yinaura/items/705d3d26710a31d2a66e)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
How to use Rails | ActiveDecorator outside View (such as Rspec test)

.name is an ordinary method. If .decorated\_name is a decorated method.

It is natural, but .name can be used normally.

     ExampleClass.first.name # => 'John' 

However, the decorated method can not be used except in View.

     ExampleClass.first.decorated_name # => NoMethodError: undefined method `decorated_method' 

If it. Let's pass the instance body to ActiveDecorator's decorator method.

     ActiveDecorator::Decorator.instance.decorate(ExampleClass.first).decorated_name # => '*J*o*h*n*' 

OK now.



# Original by
[Rails | ActiveDecorator を View 以外で使う方法 ( Rspec テストなど )](https://qiita.com/Yinaura/items/2ac43179b77c5685430f)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
bash | Remove consecutive spaces in regular expression

## problem 

I want to delete a series of spaces.

     #!/bin/bash echo ' abc' | sed 's/\s+//g' echo ' abc' | sed 's/\s*//g' echo ' abc' | sed 's/ +//g' echo ' abc' | sed 's/ *//g' 

## result 

It only moves the fourth.

      abc abc abc abc 

## Solution 

`-E` extended regular expressions with the `-E` option.

     #!/bin/bash echo ' abc' | sed -E 's/\s+//g' echo ' abc' | sed -E 's/\s*//g' echo ' abc' | sed -E 's/ +//g' echo ' abc' | sed -E 's/ *//g' 

The lower two will move.

      abc abc abc abc 

# Supplement 

See also the comments in this article. (Thank you)



# Original by
[bash | 正規表現で連続したスペースを削除する](https://qiita.com/Yinaura/items/aa90473cb4a876e4988f)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Subject and let run in reverse order for Rspec | should and is_expected

# problem 

The test should succeed for some reason. In the is\_expected I found a falling spec.

Isn't is\_expected an alias for should?

# Conclusion 

In the test where is\_expected is written, the processing order of Rspec 3 will be applied.

And.

In Rspec 2 in the order of let =\> subject. In Rspec 3 order of subject =\> let.

Processing runs in the reverse order. This is the reason.

I think that there is little to be a problem. Be careful when writing tests that depend on this order.

(It is better to change the test not to depend on it)

# verification code 

When let and subject run, try standard output to the console respectively.

     require 'spec_helper' describe do subject { p 'SUBJECT'; 'example'; } let(:example) { p 'LET'; 'example'; } context 'when Rspec 2' do it { should eq example } end context 'when Rspec 3' do it { is_expected.to eq example } end end 

`$ rspec -fd test_spec.rb`

 
# result 

      when Rspec 2 "LET" "SUBJECT" should eq "example" when Rspec 3 "SUBJECT" "LET" should eq "example" 

# Supplement 

With Rspec 2 you can also use subject! To run the subject first.

      subject! { p 'SUBJECT'; 'example'; } let(:example) { p 'LET'; 'example'; } 

With Rspec 3 you can also use let! To let let run first.

      subject { p 'SUBJECT'; 'example'; } let!(:example) { p 'LET'; 'example'; } 

But let's write a test that does not depend on this order.

# environment 

- rspec-rails 3.4.0 


# Original by
[Rspec | should と is_expected では subject と let が逆の順番で走る](https://qiita.com/Yinaura/items/048494244fd390025ac3)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | String not grep match

When searching from among strings.

String # grep does not exist.

     'ABC'.grep /B/ # => NoMethodError: undefined method `grep' 

Use String # match.

     'ABC'.match /B/ # => #<MatchData "B"> 



# Original by
[Ruby | String には grep じゃなく match](https://qiita.com/Yinaura/items/0eb78d64f788fc4a35ce)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
When you can not assign an accessor variable with Ruby | attr_accessor + initialize

# problem 

If you write `accessor = [value]` in initialize. Ruby seems to be an assignment to a local variable.

     class Book attr_accessor :price def initialize price = 1080 end end 

Even when calling the accessor. `price = 1080` which should be assigned as initial value does not come out.

     book = Book.new p book.price # => nil 

# Solution 

Write `self.price = xxxx` instead of `price = xxxx` .

     class Book attr_accessor :price def initialize self.price = 1080 end end 

     book = Book.new p book.price # => 1080 

This is ok.

# environment 

- ruby 2.0.0 


# Original by
[Ruby | attr_accessor + initialize でアクセサ変数に代入できない時](https://qiita.com/Yinaura/items/02c8bd7bd87cfa64ce6c)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Sublime Text | Shortcut to jump to any line in the file

# Move in file 

Start the file switching window with `Ctrl + p` . **_Colon +_** Enter the **_number_** of **_lines you want to move_**.

For example, if you write as follows, you can jump to the 22nd line.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/0cb74331-73c5-f3b7-4f0e-6a528479cc07.png)

# File name + number of lines 

If it is written as **file name + colon + number** of **lines**. You can jump to any number of lines simultaneously while moving to that file.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/00c2fbe6-bd56-359e-541f-54e9f2d05be1.png)



# Original by
[Sublime Text | ファイル内で任意の行にジャンプするショートカット](https://qiita.com/Yinaura/items/ec0cdeb9acfdc4601b1f)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
MySQL | Use non-alphanumeric characters and underscores in backquotes when using anything other than underscores in database names / table names

# I can not create a database 

For example, I want to create a database with a hyphenated name. But even if it writes like this.

     mysql> CREATE DATABASE example; 

It is useless.

     You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-xample' at line 1 

MySQL does not give me any kind of errors.

# Alphanumeric characters and underscores 

When using characters **_other than "alphanumeric characters" and "under bar"_** , enclose them with back quotes.

     mysql> CREATE DATABASE `example`; 

     Query OK, 1 row affected (0.01 sec) 

Other. It will work well if you enclose it in a back quote.

     CREATE DATABASE `example`; CREATE DATABASE `e/x/a/m/p/l/e`; CREATE DATABASE `e*x*a*m*p*l*e`; CREATE DATABASE `えぐざんぷる`; 

# exception 

If there is a space at the beginning or end, it is considered an invalid name. It was impossible even if it enclosed with a back quote.

     CREATE DATABASE ` example `; 

     ERROR 1102 (42000): Incorrect database name ' example ' 



# Original by
[MySQL | 英数字以外とアンダーバー 以外をデータベース名 / テーブル名に使う時はバッククォートで囲う](https://qiita.com/Yinaura/items/823c12fc1fd36bd18b63)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Vim | vim -v is beautiful

That's it.

# command 

`$ vim -v`

 
# result 

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/5c619e6e-0e5b-0599-7ba8-6eacd0404fed.png)

# version information 

See the image.



# Original by
[Vim | vim -v は綺麗](https://qiita.com/Yinaura/items/49aaa21acead14b9d18f)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
How to cancel Git | commit --amend prematurely (cancel while entering commit message)

# problem 

## Amend it! 

`$ git commit --amend`

 
## I want to quit after all! 

     Fix you brain # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # ... 

## Get out without saving! 

`:q!` (The vim command)

## Wow ah, it has been committed ah! 

      Date: Fri Dec 18 13:38:52 2015 +0900 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 you-need-amend.rb create mode 100644 but-i-walk-my-way.sh 

# Solution 1 

`commit --amend`

## 1. Delete all commit messages. 

Make no commit message. (Comments may be included)

     # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Dec 18 13:38:52 2015 +0900 

However. Because it will be committed if there is only one blank line / comment line. **_It_** would be safer to **_delete all the file contents_**. (If you keep pressing the `d` key as well)

## 2. End saving 

`:x` (the vim command)

## 3. Results 

Not committed (Return to the original)

     Aborting commit due to empty commit message. 

# Solution 2 

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/8e4e0b47-d4b4-babf-9085-ca3b0f7d44d9.png)

# How is it usually? 

In a normal commit that is not amend. It just seems OK if you exit without saving. ( `:q!` )

# environment 

- git version 2.3.8 (Apple Git-58) 
- vim 7.3 

# Aside 

I noticed later that it was clearly explained in the commit editing message.

`an empty message aborts the commit.`



# Original by
[Git | commit --amend を途中で取り消しする方法  (コミットメッセージ入力中のキャンセル)](https://qiita.com/Yinaura/items/39f3a688f591f2b175dd)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Vim | Unexpectedly do not know: x command (save + end)

`:x` .

`:w` is almost the same as quitting with `:q` after saving with `:w` .

However, the difference **is that the file is saved only when there is a change**.

* * *

Benefit: The easiest to type



# Original by
[Vim | 意外と知らない :x コマンド  ( 保存+終了 ) ](https://qiita.com/Yinaura/items/c74a09656beda6f02abb)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Git | How to rebase -i from current branch root

Set an alias.

     [alias] branch-root = merge-base master HEAD 

And

`$ git rebase -i $(git branch-root)`

 

OK.



# Original by
[Git | 現在のブランチルートから rebase  -i する方法](https://qiita.com/Yinaura/items/302c8d6b9f0f4806d812)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Qiita | When asked, write to Qiita (How to find the themes in demand)

# demand 

There is a demand for what people are asking "What is that?"

For example, when showing a person's own display and operating it. "What is that command?" **Even if it is natural to you,** it is often the **command** that **people do not know**.

Let's actively make it a neta.

# Example 

For example, in my case, every article that has a lot of stock. People were asked, "What is that?"

- [How to open file from last line in vi / vim](http://qiita.com/Yinaura/items/8e152972017189fd7085) 
- [How to increase the speed of bundle install 1.5 times. (Parallel execution)](http://qiita.com/Yinaura/items/317be4f158be9c3fa1aa) 
- [Vim | Unexpectedly do not know: x command (save + end)](http://qiita.com/Yinaura/items/c74a09656beda6f02abb) 


# Original by
[Qiita | 「それなんですか？」と聞かれたら Qiita に書こう ( 需要のあるテーマの見つけ方 )](https://qiita.com/Yinaura/items/cf40c661d5459b245480)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
$ git log-Oneline option, show log in one line

# command 

`$ git log --oneline`

 
# result 

     be72210 Update gem 'guard-rspec' 233f60b Create new resoure 'UserGroup' a54daf3 Update gem 'shoulda-matchers' 

It is refreshing!

# Supplement 

- Even if it is gugging with "git log one line", there was no page that only dealt with this topic. 


# Original by
[$ git log --oneline オプションで、ログを一行で表示する](https://qiita.com/Yinaura/items/db984a115bcd544732c1)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Rails | Convert numbers to bytes

There was such a thing.

## Part-Time Job 

     10.bytes # => 10 

## Kilobytes 

     10.kilobytes => 10240 

## Megabyte 

     10.megabytes => 10485760 

## Gigabyte 

     10.gigabytes => 10737418240 

## Terabyte 

     10.terabytes => 10995116277760 

## Petabyte 

     10.petabytes => 11258999068426240 

## Exabyte 

     10.exabytes => 11529215046068469760 

# environment 

- Rails 4.0.13 


# Original by
[Rails | 数字をバイト数に変換する](https://qiita.com/Yinaura/items/4f6591df5d7c7bf68a90)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | How to invert true and false

# set true to false 

     !(true) # => false 

# set false to true 

     !(false) # => true 

# What time is it useful? 

Useful when you want to return the opposite result. For example, if you decide not to be a woman but a man.

## With if 

Redundant.

     class Person def is_man? if is_woman return false else return true end end end 

## If you use! 

I can write more concisely.

     class Person def is_man? !(is_woman?) end end 



# Original by
[Ruby | true と false を反転させる方法](https://qiita.com/Yinaura/items/9df95ec1ff496f28387d)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | List all versions that can be installed with rbenv

# command 

`$ rbenv install --list`

 
# result 

Like this.

     Available versions: 1.8.6-p383 1.8.6-p420 1.8.7-p249 1.8.7-p302 1.8.7-p334 1.8.7-p352 1.8.7-p357 1.8.7-p358 1.8.7-p370 1.8.7-p371 1.8.7-p374 1.8.7-p375 1.9.1-p378 1.9.1-p430 1.9.2-p0 1.9.2-p180 1.9.2-p290 1.9.2-p318 1.9.2-p320 1.9.2-p326 1.9.2-p330 1.9.3-dev 1.9.3-preview1 1.9.3-rc1 1.9.3-p0 1.9.3-p125 1.9.3-p194 1.9.3-p286 1.9.3-p327 1.9.3-p362 1.9.3-p374 1.9.3-p385 1.9.3-p392 1.9.3-p429 1.9.3-p448 1.9.3-p484 1.9.3-p545 1.9.3-p547 1.9.3-p550 1.9.3-p551 2.0.0-dev 2.0.0-preview1 2.0.0-preview2 2.0.0-rc1 2.0.0-rc2 2.0.0-p0 2.0.0-p195 2.0.0-p247 2.0.0-p353 2.0.0-p451 2.0.0-p481 2.0.0-p576 2.0.0-p594 2.0.0-p598 2.0.0-p643 2.0.0-p645 2.0.0-p647 2.1.0-dev 2.1.0-preview1 2.1.0-preview2 2.1.0-rc1 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0-dev 2.2.0-preview1 2.2.0-preview2 2.2.0-rc1 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0-dev jruby-1.5.6 jruby-1.6.3 jruby-1.6.4 jruby-1.6.5 jruby-1.6.5.1 jruby-1.6.6 jruby-1.6.7 jruby-1.6.7.2 jruby-1.6.8 jruby-1.7.0-preview1 jruby-1.7.0-preview2 jruby-1.7.0-rc1 jruby-1.7.0-rc2 jruby-1.7.0 jruby-1.7.1 jruby-1.7.2 jruby-1.7.3 jruby-1.7.4 jruby-1.7.5 jruby-1.7.6 jruby-1.7.7 jruby-1.7.8 jruby-1.7.9 jruby-1.7.10 jruby-1.7.11 jruby-1.7.12 jruby-1.7.13 jruby-1.7.14 jruby-1.7.15 jruby-1.7.16 jruby-1.7.16.1 jruby-1.7.16.2 jruby-1.7.17 jruby-1.7.18 jruby-1.7.19 jruby-1.7.20 jruby-1.7.20.1 jruby-1.7.21 jruby-9.0.0.0-dev jruby-9.0.0.0+graal-dev jruby-9.0.0.0.pre1 jruby-9.0.0.0.pre2 jruby-9.0.0.0.rc1 jruby-9.0.0.0.rc2 jruby-9.0.0.0 maglev-1.0.0 maglev-1.1.0-dev maglev-2.0.0-dev mruby-dev mruby-1.0.0 mruby-1.1.0 rbx-1.2.4 rbx-2.0.0-dev rbx-2.0.0-rc1 rbx-2.0.0 rbx-2.1.0 rbx-2.1.1 rbx-2.2.0 rbx-2.2.1 rbx-2.2.2 rbx-2.2.3 rbx-2.2.4 rbx-2.2.5 rbx-2.2.6 rbx-2.2.7 rbx-2.2.9 rbx-2.2.10 rbx-2.3.0 rbx-2.4.0 rbx-2.4.1 rbx-2.5.0 rbx-2.5.1 rbx-2.5.2 rbx-2.5.3 rbx-2.5.4 rbx-2.5.5 rbx-2.5.6 rbx-2.5.7 rbx-2.5.8 ree-1.8.7-2011.03 ree-1.8.7-2011.12 ree-1.8.7-2012.01 ree-1.8.7-2012.02 topaz-dev 



# Original by
[Ruby | rbenv でインストールできる全バージョンをリスト表示する](https://qiita.com/Yinaura/items/3eaf944e74aac3c20675)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | Referencing Constants

## Definition 

If you write the constant JAPAN in the World class.

     class World JAPAN = '日本' end 

## reference 

**Class name ::** can be referred to by a **constant name**.

     World::JAPAN # => "日本" 

## Reference in class 

The class name can be omitted if it is in the same class.

     class World JAPAN = '日本' p JAPAN end # => "日本" 

# Supplement 

- I wrote because the page explaining just that wasn't hit even if I got it in "Ruby constant reference". 

# environment 

- Ruby 2.0.0 


# Original by
[Ruby | 定数を参照する](https://qiita.com/Yinaura/items/e0502c345b96174a62a4)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
There is no way to attach a YAML | anchor.

It doesn't seem like it.

I want you to be there.

# reference 

https://teratail.com/questions/1226

> Concatenation of strings seems not possible with yaml. It seems that there is only a way to put in yaml and replace it in the program like key: 'value:% {hoge}'.



# Original by
[YAML |  アンカーを結合する方法は無い。](https://qiita.com/Yinaura/items/596f115555686eea8ea2)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Rails | `bin_path &#39;: dealing with can&#39;t find gem bundler

# problem 

The bundler stopped working after raising the version of ruby. (rbenv + .ruby-versions)

`$ bundle install`

 

     /Users/yinaura/.rbenv/versions/2.2.4/lib/ruby/2.2.0/rubygems.rb:243:in `bin_path': can't find gem bundler (>= 0) (Gem::GemNotFoundException) from /Users/yinaura/projects/project/bin/bundle:4:in `<main>' 

# Solution 

The bundler reference directory has changed. The gem could not be found. So re-install bundler.

## reinstall bundler 

`$ gem install bundler`

 

This will create a bin for your ruby version.

`.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/exe/bundle`

 
## Gem reinstallation 

There is no Gem, so reinstall it.

`$ bundle install`

 

It moved by this.

# environment 

- ruby 2.0.0 =\> 2.4.4 
- Bundler version 1.11.2 


# Original by
[Rails | `bin_path': can't find gem bundler に対処する](https://qiita.com/Yinaura/items/6501619c6f5ab79ddaa5)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Make the value of Rails | validation available for external reference

# Solution 

It's a simple way. Write the validation value as a constant.

     class Book < ActiveRecord::Base TITLE_MAXIMUM_LENGTH = 100 validates :title, length: { maximum: TITLE_MAXIMUM_LENGTH } end 

# reference 

     Book::TITLE_MAXIMUM_LENGTH # => 20 

# Improvement 

It's redundant as it is. Write in one line using the return value of the constant declaration.

     class Book < ActiveRecord::Base validates :title, length: { maximum: TITLE_MAXIMUM_LENGTH = 100 } end 

# Supplement 

`Book.validators_on(:title)` method returns an array. It was troublesome to get the value of specific validation, so this method was used.

Please let me know if there is something else.

# environment 

- Ruby 2.0.0 
- Rails 4.0.0 


# Original by
[Rails | バリデーションの値を外部から参照できるようにする](https://qiita.com/Yinaura/items/e23040d1a247e2384b56)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Create a Forgery mock

## Forgery's Class? 

For example, when you want to make a mock on `Forgery(:basic).text` . `Forgery::Basic` is a class. So make a mock on it.

     require 'spec_helper' describe do subject { Forgery(:basic).text } before do allow(Forgery::Basic).to receive(:text).and_return('mocked text') end it { should eq 'mocked text' } end 

## result 

     $ rspec example_spec.rb 

The test passes.

     1 example, 0 failures 



# Original by
[Forgery の mock を作る](https://qiita.com/Yinaura/items/06879d1307278785e029)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | We cope with NoMethodError when it does not match in regular expression capture

# problem 

When using capture with regular expressions. You can back reference the matched value by hash.

     'Welcome to DIRTY House.'.match(/(?<match>DIRTY)/)[:match] # => "DIRTY" 

However, if it does not match, a NoMethodError will occur.

     'Welcome to DIRTY House.'.match(/(?<match>CLEAN)/)[:match] # => NoMethodError: undefined method `[]' for nil:NilClass 

# Solution 

As a countermeasure, if nothing is found, substitute an empty array with `||` .

     ('Welcome to DIRTY House.'.match(/(?<match>CLEAN)/) || {})[:match] # => nil 

Now returns nil instead of NoMethodError.

# environment 

- Ruby 2.0.0 


# Original by
[Ruby | 正規表現のキャプチャでマッチしなかった時の NoMethodError に対策する](https://qiita.com/Yinaura/items/61f636c9902b8b9cb196)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
How to force a language in Rails | i18n

You can specify `locale:` option.

### Example: To specify English (: en) 

     I18n.t('message', locale: :en) # => It is English 

### Example: To specify Japanese (: ja) 

     I18n.t('message', locale: :ja) # => これは日本語です 

 
## Premise 

It is assumed that it is in the following state.

### English file 

     en: message: It is English 

### File for Japan 

     ja: message: これは日本語です 

 
## trap 

By the way, it is a mistake to write as follows.

     I18n.t('en.message') # => "translation missing: en.en.message" 

     I18n.t('ja.message') # => "translation missing: ja.ja.message" 

# environment 

- Rails 4.0.0 
- i18n 0.7.0 


# Original by
[Rails | i18n で 言語を強制指定する方法](https://qiita.com/Yinaura/items/f8a5efdfa2f975a094ac)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | How to show only the newly added method excluding the inheritance source

# Conclusion 

`methods` false to the arguments of `methods` / `instance_methods` .

     Example.methods(false) 

     Example.instance_methods(false) 

# problem 

For example, if you have the following class:

     class Example < BasicObject def self.some_method end end 

When I try to list the class method.

     Example.methods 

Result is.

     [:some_method, :allocate, :new, :superclass, :freeze, :===, :==, :<=>, :<, :<=, :>, :>=, :to_s, :inspect, :included_modules, :include?, :name, :ancestors, :instance_methods, :public_instance_methods, :protected_instance_methods, :private_instance_methods, :constants, :const_get, :const_set, :const_defined?, :const_missing, :class_variables, :remove_class_variable, :class_variable_get, :class_variable_set, :class_variable_defined?, :public_constant, :private_constant, :singleton_class?, :include, :prepend, :module_exec, :class_exec, :module_eval, :class_eval, :method_defined?, :public_method_defined?, :private_method_defined?, :protected_method_defined?, :public_class_method, :private_class_method, :autoload, :autoload?, :instance_method, :public_instance_method, :nil?, :=~, :!~, :eql?, :hash, :class, :singleton_class, :clone, :dup, :itself, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :frozen?, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :extend, :display, :method, :public_method, :singleton_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :equal?, :!, :!=, :instance_eval, :instance_exec, : __send__ , : __id__] 

Many!

# Solution 

When executed with an argument of false.

     Example.methods(false) 

Result is.

     [:some_method] 

Super nice!

## Supplement 

The same is true for the display of instance methods.

     Example.instance_methods Example.instance_methods(false) 

# Aside 

I learned how to use this in "Meta-programming Ruby (second edition)". I forgot how to write specifically.

I was looking for another method in the way of `methods_without_ancestors` (example). Gugu didn't find it well. The result was an argument difference of the same method.

# environment 

- Ruby 2.2.4 


# Original by
[Ruby | 継承元を除外して、新しく追加したメソッドだけを表示する方法](https://qiita.com/Yinaura/items/c7f2a21a0f7eb3dc49cf)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Rspec | named_let does not work for match_array / contain_exactly

named\_let is a gem for Rspec. The symbol given to let displays the test result.

But.

# Test content 

     require 'spec_helper' describe do subject { [Object.new, Object.new] } named_let(:instances) { subject } it { should contain_exactly(*instances) } end 

# result 

     rspec -fd test_spec.rb 

Instead of the name given in named\_let, the content (in this case, the instance is displayed as it is.

      should contain exactly #<Object:0x007fcb73c525b0> and #<Object:0x007fcb73c52588> Finished in 0.90819 seconds (files took 11.2 seconds to load) 1 example, 0 failures 

# environment 

- named\_let (0.1.5) 
- rspec-rails (3.1.0) 


# Original by
[Rspec | named_let は match_array / contain_exactly には効かない](https://qiita.com/Yinaura/items/19feab1cfc184cdfbf00)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Git | Make it easy to rebase -i from the current branch root

# Conclusion 

Register an alias in `.gitconfig` .

(With! At the beginning, write the command directly)

     [alias] rbi = !git rebase -i $(git merge-base master HEAD) 

Run.

`$ git rbi`

 

Result is.

     pick 25cf857 Good touch the Green Green Glass pick d2057d7 Goodbye Joe he got a go me oh my oh pick 4ca967e Country load take me home 

Good vibes!

(Thank you @ pasela)

# problem 

"Rebase from the current branch root in interactive mode" This is a messy command. Even though it is used frequently. Really troublesome.

But. It is useless to register an alias in .gitconfig.

     [alias] rbi = rebase -i $(git merge-base master HEAD) 

Because `$(git merge-base master HEAD)` is a command.

However, it was found that shell commands can be registered by writing! At the beginning. So the solution is at the beginning.

# environment 

- git version 2.3.8 
- Mac (OSX) 


# Original by
[Git | 現在のブランチルートから簡単に  rebase -i できるようにする](https://qiita.com/Yinaura/items/984e743cdd7583bb8bdf)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Rails | migration does not specify the number of digits when creating integer columns in migration (the number of bytes)

### [→ I moved the article](https://qiita.com/YumaInaura/items/795aae1cce4e28195907) 


# Original by
[Rails | マイグレーションで integer カラムを作る時の :limit は、桁数指定ではない ( バイト数指定だ )](https://qiita.com/Yinaura/items/cede8324d08993d2065c)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | If you use a variable in a regular expression conditional expression, you can not assign a variable by named capture

## basic action 

If you use named capture with a regular expression (a person _with a conditional_ expression on the _left side_ ). A value is assigned to a local variable.

     /a (?<month>July)/ =~ 'Ruby is a July birth stone' month # => "July" 

## problem 

However. Using variables in match conditions does not create local variables.

     a = 'a' /#{a} (?<month>July)/ =~ 'Ruby is a July birth stone' # => 8 month #=> #<NameError: undefined local variable or method `month' for main:Object> 

The match itself is successful. The variable `month` does not exist.

## Solution 

Even in the same way. `#match` can capture normally by using the `#match` method.

     a = 'a' 'Ruby is a July birth stone'.match(/#{a} (?<month>July)/) { |matched| matched[:month] } # => July 

How nice!

However, in the case of `#match` . Local variable `month` can not be created. If you really want to make it, you should assign it to the return value.

     a = 'a' month = 'Ruby is a July birth stone'.match(/#{a} (?<month>July)/) { |matched| matched[:month] } month # => "July" 

## Note 

There is also a problem with the `#match` method. It is fine if it is the above writing method. Be careful if you use capture results in other ways.

[Ruby | We cope with NoMethodError when it does not match in regular expression capture](http://qiita.com/Yinaura/items/61f636c9902b8b9cb196)

# environment 

- Ruby 2.2.4 


# Original by
[Ruby | 正規表現の条件式に変数を使うと、名前付きキャプチャによる変数代入が出来ない](https://qiita.com/Yinaura/items/13bbc6b050b97139d0d2)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Ruby | Delete only the first element in the array (get everything after the second line)

# Solution 

`drop` it.

     ['A','B','C','D','E'].drop(1) # => ["B", "C", "D", "E"] 

# problem 

## shift return value 

If you shift the array, the **extracted element** will be the return value. It is not a **remaining element**.

     ['A','B','C','D','E'].shift => "A" 

## shift! 

`shift` is destructive in the first place. So there is no `shift!`

     ['A','B','C','D','E'].shift! # => NoMethodError: undefined method `shift!' for ["A", "B", "C", "D", "E"]:Array 

## Temporary variable 

I can get the value I want. I have to write three lines.

     alphabets = ['A','B','C','D','E'] alphabets.shift alphabets # => ["B", "C", "D", "E"] 

# past 

So far, I have been asking `[1..-1]` for arrays.

     ['A','B','C','D','E'][1..-1] # => ["B", "C", "D", "E"] 

`1` means the **second** of the array. (Not `2` ) `-1` means the **end of** the array.

# environment 

- Ruby 2.2.4 

# Acknowledgment 

- @pinzolo who taught me `drop` 
- @scivola who pointed out that `shift` is destructive in the first place 


# Original by
[Ruby | 配列で最初の要素だけを削除する ( 2行目以降を全て得る )](https://qiita.com/Yinaura/items/129f702553c5b6027bfb)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
How to use Rails | Resque

## 1. Add a gem 

Simply install resque.

     gem 'resque' 

     $ bundle install 

## 2. Write the content of execution 

Write the processing you want the worker to execute in the `perform` method of the model. Here, as a test, create a process that only outputs standard.

     class Example @queue = :default def self.perform p 'Hello Sword!' end end 

## 3. Configure settings for workers 

You only need to add one line to the Rakefile.

     require 'resque/tasks' 

## 4. Launch a worker 

`$ TERM_CHILD=1 QUEUES=* bundle exec rake environment resque:work`

 

When launched, nothing happens now. That's because workers don't hesitate until the job is registered. Let's leave it for now.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/49a5866e-f661-1c41-37ce-714939fb233a.png)

## 5. Register a job 

Let's add a job on another tab (separate window) from the worker. It's easy to use the Rails console.

`$ bundle exec rails console`

 

     irb(main)> Resque.enqueue(Example) => true 

If successful, `true` will be returned.

## 6. The job is run 

After a few seconds, let's go back to the worker tab above. **You will see** that the job **"standard output string"** is being executed.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/bc38c086-4efb-340e-3f45-799776acb454.png)

Congrats!

# Premise 

- It is assumed that a Rails project has already been created. 
- It is assumed that bundler is already installed. 

# environment 

- resque (1.25.2) 
- Rails 4.2.4 


# Original by
[Rails | Resque を動かす最小手順の使い方](https://qiita.com/Yinaura/items/715e8158b4b93c71ee36)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
If you specify as:: string in ActiveAdmin | filter, too short maxlength will be created

# Solution 

Specify `as: :numeric` for numeric type columns.

     ActiveAdmin.register Example do filter :id, as: :string end 

`as: :string` doesn't work well with as:: `as: :string` .

# problem 

When creating a filter for numeric types. `as: :string` is specified.

     ActiveAdmin.register Example do filter :id, as: :string end 

ActiveAdmin misinterprets schema information. And I put a short `<input maxlength="">` .

     <input type="xxxx" maxlength="4"> 

# Summary 

ActiveAdmin filter `as:` It's not just what input is generated in HTML.

It seems to be a specification including "How to handle data types".

(That's right, it's not a specification of `type: :text` but it just feels like a bug.)

# environment 

- activeadmin (1.0.0.pre1 e3a7354) 
- Rails 4.0.0 


# Original by
[ActiveAdmin | filter に as: :string を指定したら、短すぎる maxlength が作られてしまう](https://qiita.com/Yinaura/items/3e70f9958590bd0e5e3f)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Minimal steps to get Rails | resque-scheduler

## 1. Add a gem 

In the familiar Gemfile. Install the resque body and the resque-scheduler.

     gem 'resque' gem 'resque-scheduler' 

     $ bundle install 

## 2. Write the processing content to the model 

Write the **processing you want the worker to finally execute in** the perform method of the model. Here, as a test, create a process that only produces standard output.

     class Example @queue = :default def self.perform p 'Hello Sword!' end end 

## 3. Add settings for workers 

You only need to add two lines to the Rakefile.

     require 'resque/tasks' require 'resque/scheduler/tasks' 

## 4. Start up the resque worker 

First of all, start the worker of resque itself. (not resque-scheduler's)

`$ TERM_CHILD=1 QUEUES=* bundle exec rake environment resque:work`

 

It will be in the following state.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/49a5866e-f661-1c41-37ce-714939fb233a.png)

Let's leave this and move on to the next.

## 5. Launch the resque-scheduler worker 

**It is** necessary to **launch separately from the worker of the resque body**. So run in another window

`$ bundle exec rake resque:scheduler`

 

It will be in the following state.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/1976649b-186d-be69-35cd-a10d87dcae6b.png)

## 6. Register a job 

In addition, let's add a job in a **separate window from** the **two workers**. In other words, three windows are used.

It's easy to use the Rails console.

`$ bundle exec rails console`

 

     irb(main)> Resque.enqueue_in(5.second, Example) => true 

By the way, this means "register the job 5 seconds from now".

## 6. The job is run 

After a while, let's look at the worker of the main body of resque, which was launched in **step 1**. **You will see** that the job **"standard output string"** is being executed.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/42e9db73-d77a-0fd8-a762-093e77a17cb5.png)

Congrats!

# environment 

- resque-scheduler (4.0.0) 
- resque (1.25.2) 
- Rails 4.2.4 


# Original by
[Rails | resque-scheduler を動かす最小手順](https://qiita.com/Yinaura/items/c1b4476c7fe985262796)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->
Semi-permanently remembers Rails | pry&#39;s input history (leaves the history even when pry finishes) [Mac OS X]

# Solution 

Put rb-readline with pry-rails.

     gem 'pry-rails' gem 'rb-readline' 

`$ bundle install`

 

Launch the Rails console.

`$ bundle exec rails console`

 

This is the solution! You can use the up and down keys on the keyboard to follow previous input history.

![image](https://qiita-image-store.s3.amazonaws.com/0/90607/2445654d-e953-4f05-b6e0-14001963d2d3.png)

# problem 

pry doesn't record input history at all.

To be precise, it will remember during one session. `exit` , everything disappears at the next start.

By default all history settings are true. I also confirmed that `.pry_history` exists.

     Pry.config.history.should_save # => true Pry.config.history.should_load # => true Pry.config.history.file # => "/Users/yinaura/.pry_history" 

And despite the **history being written to**.pry\_history. **It can not only read**.

It was useless to write load processing to .pryrc.

     Pry.history.load 

However. Manually run `Pry.history.load` after launching `Pry.history.load` to load the history. But it's too much trouble to do every time.

The solution is at the beginning.

# environment 

- pry (0.10.3) 
- pry-rails (0.3.4) 
- rb-readline (0.5.3) 
- Rails 4.0.0 
- OSX Yosemit 10.10.4 

# reference 

- [Managing History · pry / pry Wiki](https://github.com/pry/pry/wiki/History#History_file) 
- [Problem loading history # 1418](https://github.com/pry/pry/issues/1418) 


# Original by
[Rails | pry の入力履歴を半永久的に記憶させる ( pry が終了しても履歴を残す ) [Mac OS X]](https://qiita.com/Yinaura/items/56caebf384d52e517387)

# About

[About this translattion](https://qiita.com/YumaInaura/items/7f6fd1e9310a6816469a)








<!-- Update From Qiita API -->

# チャットメンバー募集


何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ





# Twitter


https://twitter.com/YumaInaura


<!-- Update From Qiita API -->