Ruby on Rails Sunday, December 1, 2019

> On Dec 1, 2019, at 8:08 AM, fugee ohu <fugee279@gmail.com> wrote:
>
> When I click submit nothing happens The console only shows the request
>
> items/index.html.erb:
>
> <%= form_with model: Item, url: new_item_path(@item), method: "get" do |f| %>

Your problem is right here. You are using a GET where you want a POST, and you are GETting the items/new path when you want to POST to the items path. Rails is particular about all of these points, because it is a (mostly standard) REST framework. When you change away from these conventions, you do so on your own. You can't expect Rails to know what you want this request to do, and you can't expect anyone who follows the usual patterns to be able to help you.

Walter

>
> <div class="field">
> <%= f.select :item_type_id, nested_set_options(ItemType.all, @item_type) {|i| "#{'-' * i.level} #{i.name}" }, {:include_blank => "Select"}%>
> </div>
>
> <div class="actions">
> <%= f.submit "New item" %>
> </div>
>
> <% end %>
>
> new.html.erb:
>
> <%= render form %>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/53e9cef1-537b-4b77-8693-91b0e343f565%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4C27660A-81AA-4600-912F-C05BB69BACBC%40wdstudio.com.

No comments:

Post a Comment