views:

35

answers:

1

This is what I have in my view:

  <%= link_to_remote "Responded - Positive",
      :url => contact_path(@contact, :status => 'positive response'),
      :update => "status" %>

This is what I have as a route:

  map.resources :contacts, :has_one => :status_contact

Here is what I used in my controller:

  def create
    @status_contact = StatusContact.new(params[:status_contact])
    if @status_contact.save
      #flash[:notice] = "Successfully created status contact."
      #redirect_to @status_contact
      render :text => "Set status to #{@status_contact.status}."
    else
      render :text => "bomb"
    end
  end

My desired outcome is that for the specific Contact, it will update the attribute Contact.status with the value 'positive response' and do so via ajax.

Right now, I am getting a 404 error. What do I need to do to correct this?

This is the error that I am still getting:

POST http://localhost:3000/contacts/24?method=put&amp;status=positive+response 404 Not Found
    312ms
A: 

You're probably sending your request with the wrong verb (:post instead of :put). Which action of your controller are you trying to reach? It's probably the update action… Try to modify your link by specifying the :put method:

<%= link_to_remote "Responded - Positive", :url => contact_path(@contact, :status => 'positive response'), :method => :put, :update => "status" %>
Yannis
cool, will try that -- does it change anything if it is an "association?" Meaning contact belongs_to a status_contact table?
Angela
thanks -- it's odd -- I didn't have this problem before I changed teh associations.....I will try this...
Angela
oh I remember, I think I had a nested route....?
Angela
do I need to reference teh update action?
Angela