In my redmine plugin view, I've got this link:

<%= link_to "Add", :controller => "important_user", :action => "u_edit", :u_id => user.id, :p_id => @project.id, :method => :post %>

routes.rb:

resources :important_user do 
    collection do 
      post :u_edit
    end
  end

and controller:

class ImportantUserController < ApplicationController
  def u_edit
    puts 'edit!'
  end

  def index
    puts 'ciao'
    puts params[:p_id] 
    puts params[:u_id]
  end
end

In spite of calling the expected u_edit action, clicking on the link calls the index method (I created in a second moment to avoid the AbstractController::ActionNotFound (The action 'index' could not be found for ImportantUserController) error). I've also tried using this sort of link:

<%= link_to 'Add', { :action => 'create', :u_id => user.id, :p_id => @project.id}, :method => :post %>

But it didn't work either, returning a projects?p_id=1&u_id=1 GET 404. How could I make it call the desired u_edit action?

0 Answers