2011-12-20 3 views
0

나는 Thimothy Fisher의 "RoR Bible"으로 Ruby on Rails를 테스트 중이다. 그러나 예제 중 하나가 작동하지 않습니다. NoMethodErrorContact#new 라인 # 4 제기 : 내 contact_controller있어RoR - 정의되지 않은 메서드`merge '

undefined method `merge' for "first_name":String 


http://pastebin.com/gtjLsdt0 오류가 - 그것은 코드입니다. 난 그냥 예를의 코드를 다시 입력하고있어, 및 병합

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 

무엇이 잘못에 대한 단어가 아니었다?

답변

4

롤 예는 완전히 잘못되었습니다! 대신에이 같은 기록 STH의

: f.field_type를 사용하여 당신이 반복하여 f 방법을 제공하는 :contact 폼에 필드를 할당하기 때문에 당신은

<%= f.text_field :first_name %> 

를 작성해야

<%= f.text_field 'contact', 'first_name' %> 

! 또한 쓸 수 있습니다

<%= f.label :first_name, "description of first_name" %> 

설명서를 작성하는 대신!

// 너는 내가 싫어하는 책을 말다툼했다. "The Rails 3 Way"또는 sth를 구입할 수 있습니다. 현재의 레일 버전을 견딜 수 있습니다!

+0

업데이트를 참조하십시오 .... – davidb

관련 문제