2012-05-23 2 views
0

내 응용 프로그램에 문제가 있습니다. 볼링 게임이 있습니다. 최종 결과를 이름으로 생성합니다. 내 데이터베이스에 삽입하는 문제가볼링 앱에 데이터베이스에 삽입 할 수 없습니다.

보기 :

<%= form_for player_index_path(@player) do |f|%> 
<div class="text_field"> 
    <p> 
    <%= f.label "Spelare namn" %> 
    <%= f.text_field :name %> 
    </p> 
    <p> 
    <%= f.submit "Lägg till spelare"%> 
    </p> 
</div> 
    <%end%> 

클래스 플레이어 < 액티브 :: 자료 attr_accessible : belongs_to 이름 : 결과 끝

컨트롤러 :

def create 
@player = Player.new(params[:player]) 

if @player.save 
    render :action => "index" 
    else 
render :action => "new" 
end   
end 

이주 :

class CreatePlayers < ActiveRecord::Migration 
    def change 
    create_table :players do |t| 
     t.string "name" 
     t.references :results 
     t.timestamps 
end 

끝 끝 레일의

+0

<%= form_for player_index_path(@player) do |f|%> 

대체 당신은 당신의 모델을 보여줄 수 있습니까? –

+0

이제 모델이 생겼습니다! – Max

답변

0

시도

<%= form_for @player do |f|%> 
+0

! 그래서이 오류를 발견! # <# <클래스 : 0x34f4c58> : 0x350a768> – Max

+0

에 대해 정의되지 않은 메소드 'players_path'routes.rb와'rake routes'를 보시겠습니까? 나는 코멘트에서 읽을 수 없을 것 같아서 다른 곳에 붙여 넣을 수 있습니다 .. – ok32

+0

여기 내 레이크 루트 사진이 있습니다. http://forumbilder.se/images/4c5201212054Pd885.jpg – Max

0

버전은 무엇? 모델을 게시 할 수 있습니까?

최신 버전의 Rails 인 경우 속성을 허용 목록에 추가해야합니다.

+0

내 모델은 클래스 플레이어는 <액티브 :: 자료 #의 attr_accessible : 제목 : 몸 belongs_to : 결과 끝 내 버전을 확인하는 방법 ? – Max

+0

Gemfile을보십시오. 보석에 '철로', '3.2.3'이 표시되면 가장 최신입니다. 이 경우 attr_accessible 줄의 주석 처리를 제거하고 설정하려는 필드를 양식에 추가해야합니다. –

+0

플레이어 모델입니다. 그것은 주석 처리 된 라인입니다. –

관련 문제