0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

学習60日目

Posted at

内容

直前のページに戻るボタンを実装する

前提

  • Ruby on Railsでアプリを作成中
  • 該当部分以外の記述は省略

手順

link_to 'xxx', :back を用いる。

app/views/hoges/_form.html.erb' (「戻る」という文字にリンク機能を持たせる場合)`

<%= link_to '戻る', :back %>

(アイコンにリンク機能をもたせる場合)

<%= link_to :back do %>
  <i class="fa-solid fa-left-long"></i>
<% end %>

コメント

ルーティングのネストを深くしないための苦肉の策で実装した。
先に画面遷移等細かい部分まで詰めてから開発を始めた方が良さそう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?