Rails 3.2 `link_to` (in email) mit` method:: put` erzeugt immer noch GET request

In meiner App habe ich automatisierte E-Mails, die an Bewerbungen erinnern, um den nächsten Schritt im Interviewprozess abzuschließen. Die E-Mail hat einen Opt-Out-Link, der beim Klicken eine Controller-Aktion auslösen sollte, die ein Zustandsmaschinenereignis auslöst, um ihren Zustand in @ zu änderopted_out. Der Link funktioniert nicht und von der localhost-Konsole aus scheint es so zu sein, als ob der Link immer noch eine GET-Anfrage erzeugt, für die es keine Route gibt (der Fehler istActionController::RoutingError (Not Found):).

Hier ist die Konsole, die die unerwünschte GET-Anforderung anzeigt:

Started GET "/worker/application/opt_out.1" for 10.0.2.2 at 2014-08-29 17:08:06 +0000
Processing by LandingController#show as 
  Parameters: {"category"=>"worker/application", "location"=>"opt_out"}

Hier ist der Link

link_to 'stop getting these reminders', opt_out_worker_application_url(@worker), method: :put, style: 'background-color: #fff; color: #56A0D3; display: inline-block; margin-bottom: 5px; margin: 0px; padding: 0px; text-decoration: none'

Hier sind alle Routen für dasworker Namespace:

# routes.rb

  namespace :worker do
    resource :application, only: [:create, :new, :show] do
      member do 
        put 'opt_out' => 'application#opt_out'
      end
    end
    resources :jobs do
      member do
        post 'compete' => 'jobs#compete'
        delete 'compete' => 'jobs#withdraw'
      end
      resources :comments, only: [:create]
      resources :timesheets, only: [:create, :new, :show]
    end
    resources :banks, only: [:create, :new, :destroy]
    scope 'money' do
      root to: 'money#index', as: 'money'
      post 'withdraw' => 'money#withdraw', as: 'money_withdraw'
    end
    get 'profile' => 'profiles#show'
    root to: 'jobs#index'
  end

Hier ist die Controller-Aktion:

# applications_controller.rb

      def opt_out
        @worker = Worker.find(params[:id])
        if @worker.interview_requested? or @worker.onboarding_requested?
          if @worker.fire_state_event(:opt_out)
            AdminsMailer.sweeper_opted_out(@worker.id)
            redirect_to root_url, notice: "You have successfully opted out of the application process. We're sorry to see you go, and hope you'll consider returning in the future!"
          else
            redirect_to root_url, alert: "There was a problem. Please contact Support if you need further assistance."
          end
        else
          redirect_to root_url, alert: "There was a problem. Please contact Support if you need further assistance."
        end
      end

Hier istrake routes:

opt_out_worker_application PUT    /worker/application/opt_out(.:format)           worker/application#opt_out
                worker_application POST   /worker/application(.:format)                   worker/applications#create
            new_worker_application GET    /worker/application/new(.:format)               worker/applications#new
                                   GET    /worker/application(.:format)                   worker/applications#show

Antworten auf die Frage(2)

Ihre Antwort auf die Frage