Just trying a simple example to try to get nested to work... but can't
get it!  Been 2 days!  Please help.   VERY SIMPLE controller, view,
models... listed below.

----------------------ERROR
MESSAGE----------------------------------------------------------------------

ActiveRecord::AssociationTypeMismatch in UserController#update_player

Racquet(#38866740) expected, got Array(#20762670)

-------------------------------------------------------------------------------------------------------------------------

-----------------MODELS-------------------------------------

class Player < ActiveRecord::Base

    has_many :racquets, :dependent => :destroy

    accepts_nested_attributes_for :racquets

end


class Racquet < ActiveRecord::Base

     belongs_to :player

end

--------------CONTROLLER-----------------------------

class UserController < ApplicationController

   def index
     @player = Player.new
     @player.racquets.build
   end


   def update_player
     @player = Player.new(params[:player])
     @player.save
     redirect_to :action => :index
   end

end

----------------------- VIEW
-------------------------------------------

<div>
<% form_for :player, :url => { :action => :update_player, :id =>
@player.id } do |f| %>

  Name: <%= f.text_field :name %> <br>
  Rank: <%= f.text_field :rank %> <br>

  <% f.fields_for :racquets do |racquets_form| %>

  Racquet Name: <%= racquets_form.text_field :typ %> <br>
  <% end %>

  <%= f.submit "Submit" %>
  <% end %>
</div>

--------------------------------------------------------------------------------

This was supposed to be quick practice form to make use of nested
models.... and has turned into a nightmare.  Can anyone tell my why it
is not working???

Thanks so much,

Shawn

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to