in my web app I have a button on my homepage that takes the user to a completetask page
<%= link_to "Complete Course", home_completeTask_path(course_id: enrolment.course_id), class:"btn btn-dark" %>
This takes the user to /completeTask?course_id=2
Im wanting to also direct the user to task 0, which is just an introduction task, which i'd achieve by adding ,task_id: 0 in the link_to line above.
so the final url would include /completeTask?course_id=2&task_id=1
completeTask page
On the completeTask page, i have a list of tasks associated with each course and I want the user to be able to click one of these task buttons and be redirected/reload the same page with the selected task information.
My code line is
<%= button_to task.name, home_completeTask_path(course_id: params[:course_id].to_i, task_id: task.id ), class:"btn btn-dark" %>
This managed to change the url params when the button is clicked, yay, but it throws an error of no POST route. so I added method: :get which i believed would change the button_to from post to get.
When i run this, all params from the url are removed.
Is there an easier way to add params to url and reload a page, or how do i fix the above code lines to work as I intended.
Thanks.