Newbie REST confusion

So I am trying to do the simple action of updating user
information(the model is named spec) that may not exist in the first
place. Meaning I have one view for both new and update. I think
theres something wrong with my variables or something, not sure…but
here is my code:

in the spec controller:
def edit
@title = ‘Edit User Information’
@user = logged_in_user
@user.spec ||= Spec.new
@spec = @user.spec
end

def update
if @user.spec.update_attributes(params[:spec])
flash[:notice] = “Specs updated”
redirect_to user_path(logged_in_user)
end
end

this is the edit view:
<% form_for :spec, :url => spec_url,
:html => { :method => :put } do |form| %>

<%= @title %>
 <%= error_messages_for 'spec' %>
 <%= text_field_for form, "first_name" %>
 <%= submit_tag 'Create', :class => "submit"  %>
<% end %>

This is really confusing, but I dont think its a complicated problem.
thanks.

Hi –

On Thu, 10 Jul 2008, Dave L. wrote:

@user = logged_in_user

this is the edit view:
<% form_for :spec, :url => spec_url,
:html => { :method => :put } do |form| %>

<%= @title %>
<%= error_messages_for 'spec' %>
<%= text_field_for form, "first_name" %>

Try changing that to: form.text_field “first_name”

David


Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
Advancing With Rails August 18-21 Edison, NJ
See http://www.rubypal.com for details and updates!