I have a simple form for creating tasks which is customized with @new_task
to always create tasks. A separate form is used to update them.
#Form
<%= form_for([@project, @new_task]) do |f| %>
<%= f.text_field :title, placeholder: 'Add a Task' %>
<%= f.submit %>
<% end %>
#TasksController
def show
@projects = Project.all
@project = Project.find(params[:project_id])
@task = Task.find(params[:id])
@new_task = Task.new(title: @task.title)
@tasks = @project.tasks.all
end
The problem is when I'm on tasks/show (which calls the task ID) the form assumes it's an update and populates the text field with the task name.
I need to clear the text field so that only the "Add a Task" placeholder is visible. I've tried a number of different ways with no luck and am hoping somebody here can help.