LoginSignup
0
0

More than 3 years have passed since last update.

簡潔にflashメッセージを実装する。 ❏Rails❏

Last updated at Posted at 2019-11-13

基本の書き方

コントローラー

xxx_controller.rb
if article.save
  flash[:success] = "成功したよ!"
  redirect_to root_path
else

ビュー

xxx.html.haml
= flash[:success]



これでsaveが完了したら、フラッシュメッセージが表示されるようになったよ!
やったね!!



ではまた!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0