mizchi / TypeScript Meetup 2
- mizchi / 竹馬光太郎
- フロントエンドと Node.js
| 更新: | 2021-05-23 |
|---|---|
| 作者: | @voluntas |
| バージョン: | 2021.1 |
| URL: | https://voluntas.github.io/ |
| # | |
| # 数字 | |
| # | |
| # 全て数値(全角) | |
| /\A[0-9]+\z/ | |
| # 全て数値(半角) | |
| /\A[0-9]+\z/ |
| class MyJob < ActiveJob::Base | |
| queue_as :urgent | |
| rescue_from(NoResultsError) do | |
| retry_job wait: 5.minutes, queue: :default | |
| end | |
| def perform(*args) | |
| MyService.call(*args) | |
| end |
| import ( | |
| "crypto/md5" | |
| "encoding/hex" | |
| ) | |
| func GetMD5Hash(text string) string { | |
| hasher := md5.New() | |
| hasher.Write([]byte(text)) | |
| return hex.EncodeToString(hasher.Sum(nil)) | |
| } |
Rails 3.1 gives us a really easy way to authenticate users in our app: http_basic_authenticate_with. Using it, all we need to do is create a model for the user (certainly, User model :P) with an attribute called password_digest and some views feature for login and register users. After all, let's relax and let Rails do the hard work.
gem 'bcrypt-ruby', '~> 3.0.0'
First at all, an User model which we can generate by following:
rails g model user email:string password_digest:string
and then add the following methodo call to generated class:
has_secure_password
| # Bulk API design | |
| # | |
| # resources :posts | |
| class PostsController < ActiveController::Base | |
| # GET /posts/1,4,50,90 | |
| # post_url([ @post, @post ]) | |
| def show_many | |
| @posts = Post.find(params[:ids]) | |
| end |