0
votes

I have a problem with my application. There is a bowling game. which to generate the final result to a name. I have a problem to insert into my database

view:

 <%= 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%>

class Player < ActiveRecord::Base attr_accessible :name belongs_to :result end

Controller:

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

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

migrationen:

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

end end

2
can you show your model?Jeff Dickey

2 Answers

0
votes

Try replacing

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

with

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

What version of Rails? Can you post your model?

If it's the newest version of Rails, you have to whitelist your attributes.