samedi 20 février 2016

How to resolve ambiguity error in Rails? Undefined method '_index_path'

Rails convention urges everyone to name models, controllers and other things the way they are named in real life.

I've run into a problem, where my form can't recognize the right form of instance variable.

I have Fish model and corresponding fish controller.

class FishController < ApplicationController
  def index
    @fish = Fish.new
  end
end

Then when I get on my form, I get the error.

<%= form_for @fish do |f| %>
  <%= f.label :type %>
  <%= f.text_field :type, class: "form-control" %>
<% end %>

enter image description here

How can I resolve the issue? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire