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

  • SEARCH
  • Home
  • 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 9032179
In Process

The Archive Base Latest Questions

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

I have two controllers: workers and tasks. this is the variable index of the

  • 0

I have two controllers: workers and tasks.

this is the variable index of the tasks_controller:

def index
   @task = Worker.where(:name => params[:worker_id])

   respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @worker }
    end
end

this is my index.html.erb of Tasks:

<table>
  <% @task.each do |task| %>
    <tr>
      <td><%= task.name %></td>
      <td><%= task.task %></td>
      <td><%= task.done %></td>
      <td><%= link_to 'Edit', edit_worker_task_path(task.name,1) %></td>
    </tr>
  <% end %>
</table>

I have to know what is the id of the task (for example, I set ‘1’).

enter image description here

I attach my rake routes command:

enter image description here

This is my edit of the task (I just wanted to see if I get the relevant task):

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

and this is my models/worker.rb:

class Worker < ActiveRecord::Base
   attr_accessible :done, :name, :task
end
  • 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:54:57+00:00Added an answer on June 16, 2026 at 7:54 am

    To link to the edit page for a particular task, just this will do:

    <%= link_to 'Edit', edit_worker_task_path(task) %>
    

    If that is a nested route you probably want to ensure there is a edit_task route so you can do this:

    <%= link_to 'Edit', edit_task_path(task) %>
    

    But as your @task variable is actually a collection of Worker models, if you called the edit_task_path(task) helper then you’ll end up on the edit task page, but it’ll have passed through the id of a Worker. Does that make sense?

    Edit
    After a bit of a chat, we created the necessary Task and Worker models, sorted out the migrations and routes.rb file. Then pointed him towards new_worker_task_path(worker) and looked at the worker index page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two controllers: workers and tasks. views/workers/index contains: <% @workers.group_by(&:name).each do |name, workers|
I have two controllers: tasks, tasksperson. I have views/tasks/index.html.erb: <table> <% @tasks.group_by(&:name).each do |name,
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have
I have two controllers, orders and tasks - each order has many tasks. In
I have two controllers: Users and Static . Static/index is my root index page.
i have two controllers with the same name in different sub folder My Controllers
I have two controllers with the same name. One with a [get] and the
I have two controllers: test.php public function trackback() { $this->load->library('trackback'); $tb_data = array( 'ping_url'
I have two controllers - how can I call the functions in them from
I have two view controllers in a tabbar which can both edit data. Therefore,

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.