1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby on Rails <2021年> かんたんログイン機能の実装(form_with)

Posted at

前提条件

  • gem 'devise' でログイン機能を実装していること
  • 新規登録で mail: guest@guest, password: 111111で登録していること
 <%= form_with(model: User.new, url:new_user_session_path) do |f| %>
   <%= f.hidden_field :email, value: "guest@guest" %>
   <%= f.hidden_field :password, value: "111111" %>
   <%= f.submit "ゲストログイン", class:"btn btn-success btn-sm mb-3 btn-block guest"%>
<% end %>

ゲストログインがクリックされるとログイン画面へ行き、
valueの中のemailとpasswordが入り
ログインした画面へリダイレクトされます。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?