Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9028881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:06:43+00:00 2026-06-16T07:06:43+00:00

I have two controllers: workers and tasks. views/workers/index contains: <% @workers.group_by(&:name).each do |name, workers|

  • 0

I have two controllers: workers and tasks.

views/workers/index contains:

<% @workers.group_by(&:name).each do |name, workers| %>
  <tr>
    <td><%= name %></td>
    <td><%= workers.size %></td>
  </tr>
<% end %>

It shows me all the workers and their number of tasks.

I want to add a another <td> that is named: “show all tasks” and shows all the tasks of worker X.

in order to do that, I think I need something like:

<td><%= link_to 'show all tasks', worker_task_path(name) %></td>

thus, I have tasks_controller:

def index
    @task = Worker.where(:name => params[:id]) respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @worker }
    end
end

and this is views/tasks/index:

<% @task.each do |task| %>
  <tr>
    <td><%= task.name %></td>
    <td><%= task.task %></td>
    <td><%= task.done %></td>
  </tr>
<% end %>

In addition, I defined routes.rb:

TODO::Application.routes.draw do
   #resources :workers
   #root to:"workers#index"

   match '/workers/:id/index', :to => 'tasks#index', :as => 'index_task'

   resources :workers do
   resources :tasks

end

I think I didn’t define the routes.rb correctly, because my error is:

Routing Error

No route matches {:action=>"show", :controller=>"tasks", :worker_id=>"alon"}
Try running rake routes for more information on available routes.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:06:45+00:00Added an answer on June 16, 2026 at 7:06 am

    First, you could simplify your routes by removing the unnecessary match directive. By declaring :

    resources :workers do
        resources :tasks
    end
    

    you nested the tasks resources into the workers ones. Your tasks index will then be accessible using :

    workers/:id/tasks
    

    where id is the primary key of your worker model.

    Rails path helpers are sensitive to the singular / plural form. The path in the link_to call corresponds to a specific worker (singular) containing a list of tasks (plural). Rails router expects a primary key or a model instance as the id parameter :

    <%= link_to 'All tasks', worker_tasks_path(worker) %>
    or
    <%= link_to 'All tasks', worker_tasks_path(worker.id) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two controllers: tasks, tasksperson. I have views/tasks/index.html.erb: <table> <% @tasks.group_by(&:name).each do |name,
I have two controllers: workers and tasks. this is the variable index of the
I have two controllers, orders and tasks - each order has many tasks. In
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have
I have two controllers: Users and Static . Static/index is my root index page.
I have two controllers: Tasksadmins and Workers. I defined two roots, but someone told
i have two controllers with the same name in different sub folder My Controllers
I have two controllers A & B In B there are one label and
I have two view controllers. My first is my menu which contains my highscore
I have two controllers with the same name. One with a [get] and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.