# Can not call RJS and throwing error

**URL:** <https://www.ruby-forum.com/t/can-not-call-rjs-and-throwing-error/189466>\
**Category:** Rails\
**Created:** [June 1, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/can-not-call-rjs-and-throwing-error/189466 "2010-06-01T13:57:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![venu1234](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/41988e/32.png) [@venu1234](https://www.ruby-forum.com/u/venu1234)\
**Post date:** [June 1, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/can-not-call-rjs-and-throwing-error/189466/1 "2010-06-01T13:57:41Z")

</div>

I created controllers of project and task and appropraite html pages for  
them and created two partials of fields and tasks and having link in  
fields partial, when i call it it is throwing RJS error, please find the  
code below and mention a solution for geting text box dynamically…

My Html page

\<% form\_for :project, :url =\> projects\_path do |f| %\>  
\<%= render :partial =\> ‘fields’, :locals =\> { :f =\> f } %\>

\<%= submit\_tag "Create Project" %\>

\<% end %\>

Fields Partial

\<%= error\_messages\_for :project %\>

Name: \<%= f.text\_field :name %\>

 \<%= render :partial =\> 'task', :collection =\> @project.tasks %\>

\<%= link\_to\_function('Add') do |page| page.visual\_effect :highlight, 'tasks' end%\>

Task partial

\<% @task = task %\>  
\<%= error\_messages\_for :task %\>

 \<% fields\_for\_task(task) do |task\_form| %\> 

Task: \<%= task\_form.text\_field :name %\> \<%= link\_to\_function "remove", "$(this).up('.task').remove()" %\>

 \<% end %\>

My controller

class ProjectsController \< ApplicationController

def index  
@projects = Project.find(:all)  
end

def new  
@project = Project.new  
@project.tasks.build  
end

def create  
@project = Project.new(params[:project])  
if @project.save  
flash[:notice] = “Successfully created project and tasks.”  
redirect\_to projects\_path  
else  
render :action =\> ‘new’  
end  
end

def edit  
@project = Project.find(params[:id])  
end

def update  
params[:project][:existing\_task\_attributes] ||= {}

@project = Project.find(params[:id])  
if @project.update\_attributes(params[:project])  
flash[:notice] = “Successfully updated project and tasks.”  
redirect\_to project\_path(@project)  
else  
render :action =\> ‘edit’  
end  
end

end
