I have having some trouble with my update statement. I have a page that
allows users to change their personal information (name,
password...etc), The update statement seems to execute successfully but
does not update anything. What am I missing?

MODEL CODE
-----------
class Player < ActiveRecord::Base
  has_many :statistics
  has_many :ladders, :through => :statistics

  validates_presence_of :first_name, :last_name, :login, :password
end


CONTROLLER CODE
----------------
  def edit
    @player = Player.find(params[:id])
  end

  def update
    Player.update(params[:id],
    {:first_name => params[:first_name],
    :last_name => params[:last_name],
    :login => params[:login],
    :password => params[:password]})
    flash[:notice] = "Personal information updated sucessfully
#{params[:id]}"
    redirect_to player_path(@current_player)
  end


VIEW CODE
----------
The edit method is called from another view as follows

<p>
  <% form_tag(edit_player_path(@player), :method => "get") do %>
    <%= submit_tag 'Edit personal information' %>
  <% end %>
</p>

EDIT VIEW
----------
<h2> Edit personal information </h2>
<%= render :partial => 'form' %>

FORM VIEW
----------
<%= error_messages_for 'player' %>
<% form_for(@player) do |f| %>
  <p>
  First Name:<br>
  <%= f.text_field :first_name %>
  </p>
  <p>
  Last Name:<br>
  <%= f.text_field :last_name %>
  </p>
  <p>
  Username:<br>
  <%= f.text_field :login %>
  </p>
  <p>
  Password:<br>
  <%= f.password_field :password %>
  </p>
  <p>
  <%= submit_tag "Save" %>
  </p>
<% end %>
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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