Search code examples
ruby-on-railsformsobserver-pattern

observe_form url confusion


i cannot seem to get observe_form to call a particular action

i have a route defined

map.resources :charges, :collection => {:charge_total => :get}

my controller

class ChargesController < ApplicationController
  def charge_total
    return 'foo'
  end
end

my view: i have tried both...

observe_form form_id, :update => :charge_total, :url => :charge_total_charges

and

observe_form form_id, :update => :charge_total, :url => {:controller => :charges, :action => :charge_total}

when the form updates, i get an unknown action error

No action responded to update. Actions: charge_total, create

it sees that there is an action charge_total, however it is trying to respond to update? im not sure what is going on. any thoughts?


Solution

  • bahh! put, not get...

    map.resources :charges, :collection => {:charge_total => :put}