form not loading for get request

This request has some utf8 in between “item_type_id” and “=”

GET /items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=9&commit=New+item HTTP/1.1

It’s normal that rails adds a hidden field with the name utf8 and a check as the value, when you submit a form using GET the hidden field goes there with the other fields, there’s nothing wrong there.

You should have some error on the console if something is not working, that utf8 parameter is ok.

That’s the last thing in the console Here’s my form:

<%= form_with(model: @item, url: new_item_path(@item), method: “get”) do |f| %>

 <div class="field">
     <%= :item_type_id, nested_set_options(ItemType.all, @item_type) {|i| "#{'-' * i.level} #{}" }, {:include_blank => "Select"}%>

<div class="actions">
    <%= f.submit "New item" %>

<% end %>

I guess I’d better explain the form I just posted is from the index view and on submit it’s supposed to launch the new action and load the next form

The form looks ok, the parameters on the request too, it’s impossible to tell you something else if you have nothing on the logs (rails and the browser’s network tab) that could indicate an error

It gets a 500 response - - [01/Dec/2019:08:25:49 EST] “GET /items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=1&commit=New+item HTTP/1.1” 500 0
http://localhost:3000/items -> /items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=1&commit=New+item
How do I find the error?

What’s your log level value? make sure it’s “debug” on your environment

Now I get 200 response and the log says it rendered items/_form.html.erb but the order of operations looks backwards First it renders the form then there’s the get request to the new action Shouldn’t the get request to the new action come first?

Started GET “/items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=1&commit=New+item” for at 2019-12-01 09:56:33 -0500
Processing by ItemsController#new as JS
Parameters: {“utf8”=>“✓”, “item”=>{“item_type_id”=>“1”}, “commit”=>“New item”}
ItemProperty Load (0.7ms) SELECT item_properties.* FROM item_properties WHERE (item_type_id=‘1’)
Rendering items/new.html.erb within layouts/application
ItemType Load (0.7ms) SELECT item_types.* FROM item_types WHERE = 1 LIMIT 1
Rendered items/_form.html.erb (9.2ms)
Rendered items/new.html.erb within layouts/application (13.9ms)
Completed 200 OK in 48ms (Views: 39.8ms | ActiveRecord: 1.4ms) - - [01/Dec/2019:09:56:33 EST] “GET /items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=1&commit=New+item HTTP/1.1” 200 1749
http://localhost:3000/items -> /items/new?utf8=%E2%9C%93&item%5Bitem_type_id%5D=1&commit=New+item