[RUBY] [Form with two arguments] rails, form_for / form_with arguments



■ Understanding form ■ Understanding the association

【Development environment】

■ Mac OS catalina ■ Ruby on Rails ( ■ Virtual Box:6.1 ■ Vagrant: 2.2.7

In the curriculum

form_for[@post, @comment].....


up until this point, form_for(@post)....

There was one argument, why two? ?? ??

The reason is that you have to pass two arguments.

In this case, because it is ** association **

Post: comment = 1: Many

So we need to give a value to both post and comment ...


Become form_for [@post, @comment] !!!!

that's all, If you have any corrections, please FB! !!

[I want to read it together]

■ About comment function implementation https://qiita.com/tanaka-yu3/items/93d94b1ede8fb4be2981

■ About form_with https://qiita.com/tanaka-yu3/items/50f54f5d4f4b8dfe19f3

■ Method list https://qiita.com/tanaka-yu3/items/89abad875187494bec53

Recommended Posts

[Form with two arguments] rails, form_for / form_with arguments
[Form_with] Let's unify form with form_with.
[Rails] Two ways to write form_with
[Rails] form_with
pass two arguments to the URI with link_to
Rails deploy with Docker
[Rails 6] RuntimeError with $ rails s
Handle devise with Rails
[Rails] Test with RSpec
[Rails] Development with MySQL
Supports multilingualization with Rails!
About form. ○○ of form_with
Delve into Rails form_with
[Rails] Completely understand form_with
Double polymorphic with Rails
I came across a guy with two dots in Rails