Question

I've tried to follow the Rails docs when constructing a form_for under a namespace.

The pecularity with my case is that I'm rendering one form for each object instance, all together in the index view (see code below).

Why do I get the following error message:

"undefined method `textfield' for #  < ActionView::Helpers::FormBuilder:0x00000103f04188>"  

routes.rb:

namespace :admin do
  resources :plans
end

controllers/admin/plans_controller.rb:

def index
  @plans = Plan.all
end

views/admin/plans/index.html.erb:

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @plans.each do |plan| %>
      <tr>
        <%= form_for [:admin, plan] do |f| %>
        <td><%= f.textfield :title %></td>
        <td><%= f.submit "Save" %></td>
        <% end %>
      </tr> 
    <% end %>     
  </tbody>
</table>
Was it helpful?

Solution

It's Synatx issue it's f.text_field

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top