Hi, this is probably a very easy problem to solve but ive googled and
searched this site no end and cant find a suitable solution - to be fair
im not really sure of the appropriate search terms.
Im praticing ruby by making a simple todo list. I have two tables
projects and tasks. In my main “index” view Ill have two distinct areas.
The left side will list all projects titles vertically with one in
‘focus’. In the right area i want to list all tasks associated with that
in “focus” project. If a user clicks on a different project on the left
the tasks are updated.
How do I go about creating these project links wihtout creating
individual actions for each project title.
Im wondering if i should be using link_to for this in my view, should i
link it back to my index view perhaps passing my params[:project_id] via
the link_to ??
\id also need to have soem code in my controller
def index
@all_projects = Project.find(:all)
#coming from somewhere else than the index view so choose a project to
be in focus initially
if Coming_from_somewhere_else
@in_focus_project = all_projects.first
@in_focus_asscociated_tasks = get_project_tasks(@in_focus_project.id)
#user clicked on a project link from within the view itself
else
@in_focus_project = Project.find(params[:id])
@in_focus_asscociated_tasks = get_project_tasks(@in_focus_project.id)
end
end
and then have the same index view loop through
@in_focus_asscociated_tasks to list the tasks.
is this the right way of going round this?