how to use form_with

48 views
Skip to first unread message

fugee ohu

unread,
Nov 18, 2019, 2:24:53 PM11/18/19
to Ruby on Rails: Talk
Trying to build a rails 5.2 form using form_with I get this error: ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):

<%= form_with @item, url: new_item_path, method: 'get' do |f| %>

     <div class="field">
        <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
     </div>

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

<% end %>

Rob Zolkos

unread,
Nov 18, 2019, 2:56:24 PM11/18/19
to rubyonra...@googlegroups.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-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/06504cd7-6a1a-4d24-84a3-c63f5113197c%40googlegroups.com.

fugee ohu

unread,
Nov 18, 2019, 3:02:58 PM11/18/19
to Ruby on Rails: Talk


On Monday, November 18, 2019 at 2:56:24 PM UTC-5, Rob Zolkos wrote:
On Mon, Nov 18, 2019 at 2:25 PM fugee ohu <fuge...@gmail.com> wrote:
Trying to build a rails 5.2 form using form_with I get this error: ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):

<%= form_with @item, url: new_item_path, method: 'get' do |f| %>

     <div class="field">
        <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
     </div>

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

<% end %>

--
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 rubyonra...@googlegroups.com.

Yea 

fugee ohu

unread,
Nov 18, 2019, 3:20:23 PM11/18/19
to Ruby on Rails: Talk


On Monday, November 18, 2019 at 2:56:24 PM UTC-5, Rob Zolkos wrote:
On Mon, Nov 18, 2019 at 2:25 PM fugee ohu <fuge...@gmail.com> wrote:
Trying to build a rails 5.2 form using form_with I get this error: ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):

<%= form_with @item, url: new_item_path, method: 'get' do |f| %>

     <div class="field">
        <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
     </div>

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

<% end %>

--
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 rubyonra...@googlegroups.com.



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


     <div class="field">
        <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
     </div>

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

<% end %>

 ActionView::Template::Error (wrong number of arguments (given 5, expected 1..4)):

Walter Lee Davis

unread,
Nov 18, 2019, 3:31:13 PM11/18/19
to rubyonra...@googlegroups.com
Which item in the code you shared is being given five arguments? Look there. (It's not the form_for.)

Walter



Reply all
Reply to author
Forward
Message has been deleted
0 new messages