link_to question
I'm working on a project management app that has a dashboard which links to tasks that are overdue, due today, this week, next week etc.
I can display the task titles fine but can't get the links to work. I also want to display the associated project each linked task belongs to, but can't get that to work either.
The problem seems to be my inability to call the associated project ID for each task.
Controller:
def index
@project = Project.new
@projects = Project.all
@tasks = @project.tasks.all
# Custom Scopes
@tasks_overdue = Task.overdue
@tasks_today = Task.today
end
View:
<% @tasks_overdue.each do |task| %>
<%= link_to task.title, project_task_path(@project, task) %>
<br>
<%= @project.project_title %>
<% end %>
Since this page is on today#index I can't pull an ID from the address bar. Normally something like @tasks = @project.tasks.all
works fine, just not in this case.
Is there any way I can pull the ID for the project associated with each task, since I can iterate through those without issue?