I try to ask my question more clearly because I think that people didn’t understand me:
I have an application of: TODO LIST in RUBY ON RAILS.
I want to create something like:

I succeeded to create the first part (Tasks Workers), but only the: name, num_of_tasks, num_tasks_left.
now I want to create the: “Show Tasks”.
when the user pressed the link of: “tasks”, he will be direct to a page with all of the tasks (with options for edit and delete).
for example, if the user pressed the link of “tasks” in the line of a person with a name of “Alon”, he would direct to a page that will show him the second part (Tasks Of Alon).
what should I need to add in order to get this output? for meantime I have a tasks_controller.
before I explain another thing, I want to let you know about the first part (Tasks Workers). there is a variable: name. in each row, I print the variable name (he passes all the database).
Why can’t I do the next steps?
1) add a variable in tasks_controller:
def show_tasks
@tasks = Task.where(:name => params[:name])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tasks }
end
end
2) define: show_tasks.html.erb that will show the second part(Tasks Of X)
3) create a link in index.html.erb by:
<td><%= link_to 'tasks', show_tasks_path(name) %></td>
and then for each line, the ‘name’ variable will be sent to show_tasks.html.erb.
thanks for help!
You should use nested resources. Google can help you to find documentation about it.
(or click here: http://guides.rubyonrails.org/routing.html#nested-resources )
Basically, you would have 2 controllers in your case:
TasksController and WorkersController (or TaskWorkersController)
Your routes.rb should contain something like this:
This will generates the Paths & Helpers you need. Refer to the doc, if you can’t find how to do it I can help you a little but it shouldn’t be too hard 😉
Some tips:
Your
show_tasksaction will become theindexaction of the TasksController, which would be like:Your action where you display all the Workers (Alon, Dan, etc) will be the
indexaction of the WorkersController.Good luck!