Home How to replace form_for with form_with for sessions
Reply: 1

How to replace form_for with form_with for sessions

Eduardo Álvarez
1#
Eduardo Álvarez Published in 2018-01-12 17:43:14Z

I am new to Ruby-on-Rails. Currently, in my login form I have

<%= form_for(:session, url: login_path) do |f| %>

I want to replace form_for with form_with. I have tried:

<%= form_with :session, url: login_path do |f| %>

and

<%= form_with model: :session, url: login_path do |f| %>

But in both cases I get errors in the session controller.

Any help is greatly appreciated.

Anees Muhammed
2#
Anees Muhammed Reply to 2018-01-12 17:47:40Z

You have to use scope to make it work

<%= form_with scope: :session, url: login_path do |form| %>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.349944 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO