Yuto Blog
Yuto Blog

【 Ruby on Rails 】自分のFlash message をカスタムする

Copy app/controllers/application_controller.rb
1
2
3
class ApplicationController
  add_flash_types :good, :bad
end
Copy app/controllers/users_controller.rb
1
2
3
4
5
class UsersController < ApplicationController
  def create
    redirect_to root_path, good: "Created user!"
  end
end
Copy app/views/users/index.html.erb
1
<%= good %>
Updated by Yuto at 2023-05-09 21:05
Rate this article: 5/5 (45 ratings)
You didn't rate yet
Le Minh Thien Toan

Tác giả:Yuto Yasunaga

Xin chào các bạn. Mình là kỹ sư IT đang làm việc ở Nhật Bản. Mình tạo blog này để chia sẻ về cuộc sống và những kinh nghiệm trong quá trình học tập và làm việc.
Hy vọng bài viết này sẽ có ích cho bạn.