Reputation: 614
I'm studing Ruby on Rails with the "RoR Bible" by Thimothy Fisher. But one of the examples doesn't work. It's code - http://pastebin.com/gtjLsdt0
The error is: NoMethodError
in Contact#new
where line #4 raised:
undefined method `merge' for "first_name":String
that's my contact_controller. I'm just retyping example's code, and there weren't any words about merge
class ContactController < ApplicationController
def index
@contacts = Contact.find(:all);
end
def show
end
def new
@contact = Contact.new;
end
def create
end
def update
end
end
What is wrong??
Upvotes: 0
Views: 1491
Reputation: 8954
Lol that example is completely wrong!
Instead of writing sth like this:
<%= f.text_field 'contact', 'first_name' %>
You should write
<%= f.text_field :first_name %>
Because by using f.field_type
you assign the field to the :contact
form which provides the f
methods by iteration! Also you can write
<%= f.label :first_name, "description of first_name" %>
Instead of writing it manual!
// I loked up the book you refered it seems to be quit outdated. You may buy "The Rails 3 Way" or sth. that can hold up to the current rails version!
Upvotes: 4