Home>

I want to get a character string from form, search based on it, get id, and save it.

{"authenticity_token" =>"/ TKs6e3qkDuhkSKcfeIrRLvLjQTIDSyp4mKkx/JmEAjfYlulmpasI2nIN9RShVpKAq0LsPMhmBZbGRhz + hTV9Q ==", "borrow" =>

It seems that the value of the string name can be obtained, but it cannot be obtained with params [: name].

Corresponding source code

This is the part of borrow_params below

class BorrowsController</pre>
<pre><code data-language = "HTML"><% = form_with (model: borrow, local: true) do | form |%>
<% if borrow.errors.any?%>
    
     <% = pluralize (borrow.errors.count, "error")%>prohibited this borrow from being saved: 
    <ul>
      <% borrow.errors.full_messages.each do | message |%>
        <li><% = message%></li>
      <% end%>
    </ul>
    
<% end%>
  
  <% = form.label: name%>
  <% = form.text_field: name%>
  
  
  <% = form.submit%>
  
<% end%>
What I tried

Nothing is displayed for logger.debug (params [: name]) in borrow_params, and ActiveRecord_Relation: ~ and Unpermitted parameter for logger.debug (equips) when equips = Equip.where (name: params [: name]) :: name is displayed,
When I replaced the params [: name] part with a concrete string, only ActiveRecord_Relation: ~ was displayed.

  • Answer # 1

    "borrow" =>{"name" =>"Mavic mini"},
    So
    params [: borrow] [: name]
    is

Related articles