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| %> <fieldset> <legend><%= @title %></legend>
<%= error_messages_for 'spec' %> <%= text_field_for form, "first_name" %> <%= submit_tag 'Create', :class => "submit" %> </fieldset> <% end %>
This is really confusing, but I dont think its a complicated problem. thanks.