나는 내가 이것에 초보자라는 것과 나는 가치가 없다는 것을 알고있다. 그러나 누군가 나를 설명해 주었다. 여기 내가 한 일이있다. 내 기존 레일 애플 리케이션에 내 데이터베이스에 대한 새로운 마이 그 레이션을 생성하고 마이 그 레이션은 "프로필"이라고합니다. db : migrate를 실행 한 다음 이전 "new.html.erb"양식을 편집하기 시작했습니다. 코드는 다음과 같습니다레일 앱에 메소드 없음 오류가 발생하는 이유는 무엇입니까?
class CreateProfiles < ActiveRecord::Migration
def self.up
create_table :profiles do |t|
t.string :major
t.string :year
t.string :books_sell
t.string :books_buy
t.string :facebook
t.string :restaurants
t.string :interests
t.timestamps
end
add_index :profiles, :major
add_index :profiles, :year
add_index :profiles, :books_sell
add_index :profiles, :books_buy
add_index :profiles, :facebook
add_index :profiles, :restaurants
add_index :profiles, :interests
end
def self.down
drop_table :profiles
end
end
을 기본적으로, 나는 내 응용 프로그램 상에 프로필 섹션을 추가하고,하지만이 무엇입니까 :
undefined method `major' for #<User:0x00000100b6e030>
Extracted source (around line #23):
20: </div>
21: <div class="field">
22: <%= f.label :"major" %><br />
23: <%= f.text_field :major %>
24: </div>
이 내 의견/사용자/new.hmtl.erb입니다 파일 :
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirmation" %><br />
<%= f.password_field :password_confirmation %>
</div>
<div class="field">
<%= f.label :"year" %><br />
<%= f.text_field :year %>
</div>
<div class="field">
<%= f.label :"major" %><br />
<%= f.text_field :major %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
무엇이 누락 되었습니까?
귀하의 양식은'사용자'모델을위한 것이고 귀하의 이주는'프로필'모델을위한 것입니다. 이것이 당신 문제일까요? –
@Benoit Garret, 나는 당신이 그 자리에 올랐다 고 생각합니다. 나는 그것을 들여다 볼 것이다. – Tony
진지하게, 초보자 인 것에 대해 사과하지 마십시오. 이 스레드는 초보자 질문에 대한 읽기 : http://meta.stackexchange.com/questions/97327/can-i-ask-newbie-and-basic-questions-in-stack-overflow. –