link_to_unless_current fails when processing forms with error messages in it with restful routes


does anyone know how to prevent the failing mechanism of

f.e.: I have my page navigation with

link_to_unless_current "new task", new_task_path

When I click on the link, i come to the new taks path form... And no
link is created -> ok. Then I put incorrect values in the form and

The TasksController processes the "create" action, the validation for
the ActiveRecord-model fails because of the incorrect data and the
controller renders the "new" action (and includes the error messages
for the model).

class TasksController < ApplicationController
    def create
        @task =[:task])

            flash[:notice] = 'task was successfully created.'
            render :action => "new"

But here the link gets created! -> Because of the difference between
the urls:

  link path = new_task_path


  posted path = tasks_path with :method => :post

Does anybody know how to cleanly solve this problem?


ou can do it with link_to_unless instead of link_to_unless_current:

link_to_unless(controller_name == 'tasks' &&
                 (action_name == 'new' || action_name == 'create'),