There was such a form, but what did scope mean?
ruby.rb
<%= form_with scope: :session, url: sessions_path do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
Let's take a look at the verification tool for the time being I see, it works like this.
<form action="/sessions" method="post" data-remote="true">
<input type="text" name="session[name]">
</form>
The value given to the spope object is the prefix of the name value
name = "session[name]"
The parameters are sent in the form of. That
It's not difficult to think because session is just added to the parameter prefix.
controller.rb
def create
#Session the value sent using the scope[:user_id]Substitute in
session[:user_name] = session_params[:name]
end
It means that it works like this. It wasn't a big deal.
That's all for today. form_with There are so many different things.
*** 87 days to become a full-fledged engineer ***