mercredi 18 novembre 2015

Rails (erb) labelling fields / areas causing NoMethodError

So I searched all the results around the above title and none of them are giving me a solution - one thread came close but wasn't right.

My RoR code inside new.html.erb:

<class="row">
    <%= form_for @contact do |f| %>
        <%= f.label :name %>
        <%= f.text_field :name %>

        <%= f.label :email %>
        <%= f.text_field %>

        <%= f.label :comments %>
        <%= f.text_area %>
    <% end %>
</div>

Causing the following error: Image of Error

My routes.erb file has:

resources :contacts

My contacts.erb file:

class Contact < ActiveRecord::Base  
end

My contacts_controller file:

class ContactsController < ApplicationController
    def new
        @contact = Contact.new
    end

    def create
    end
end

So I need to find what I did wrong - I do not want to have to start from scratch again :(

Aucun commentaire:

Enregistrer un commentaire