regmiprem
regmiprem

Reputation: 735

url action is not working in my rails

I made a salaries controller inside the folder employee.

In my routes:

namespace :employee do
  resources :salaries
end

Now in my salaries controller I added a new method action_list:

class Employee::SalariesController < ApplicationController
  def action_list
  end
end

From view inside index I want to call action_list like:

<%= form_for :form, :url => {:action => 'action_list'}, :method => :post,
    :html => {:id => 'form1', :onsubmit => "return checkCheckBoxes();"} do |f| %>

When I submit the form I get the following error:

No route matches [POST] "/employee/salaries/action_list"

What could be the problem? It works fine for other controllers without using a namespace. What am I doing wrong?

Upvotes: 0

Views: 80

Answers (2)

Syed Aslam
Syed Aslam

Reputation: 8807

Add a route for the action_list action:

namespace :employee do 
  resources :salaries do 
    post 'action_list'
  end
end

Read more about adding restful routes here.

Upvotes: 1

bullfrog
bullfrog

Reputation: 1633

have you added action_list onto your routes

namespace :employee do
  resources :salaries do
      post :action_list, :on => :collection
  end
end

Upvotes: 1

Related Questions