# Link\_to\_remote object missing

**URL:** <https://www.ruby-forum.com/t/link-to-remote-object-missing/143878>\
**Category:** Rails\
**Created:** [July 23, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/link-to-remote-object-missing/143878 "2008-07-23T13:50:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@eyp](https://www.ruby-forum.com/u/eyp)\
**Post date:** [July 23, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/link-to-remote-object-missing/143878/1 "2008-07-23T13:50:39Z")

</div>

Hello, I’m in troubles trying to use ‘link\_to\_remote’ on Rails 2.1.  
Having this page:

#### Editing project
\<% form\_for(:project, :url =\> project\_path(@project), :html =\> { :method =\> :put }) do |f| %\> 

Name \<%= f.text\_field :name %\> Date \<%= calendar\_date\_select :project, :target\_date, :time =\> false %\> \<%= image\_submit\_tag('accept.png', :alt =\> "Update", :class =\> 'icon') %\> \<%= link\_to\_remote image\_tag('cross.png', :alt =\> 'Cancel'), :url =\> cancel\_edit\_project\_path, :method =\> :get %\>

\<% end %\> \<% form\_remote\_for(:project, :url =\> add\_contributor\_project\_path(@project), :html =\> { :method =\> :put }) do |f| %\>
#### Contributors
 Add contributor \<%= text\_field\_tag 'contributor' %\> \<%= image\_submit\_tag('add.png', :class =\> 'icon') %\> \<% end %\> \<%= render :partial =\> 'contributors', :object =\> @project %\>

And the contributors partial:

 \<% for contributor in @project.contributors %\> - delete\_contributor\_project\_path(@project),  
:method =\> :put, :contributor\_id =\>  
contributor.id %\>  
\<%= contributor.user.name %\>  

  
\<% end %\>

I get this error:

ActionView::TemplateError (You have a nil object when you didn’t  
expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]) on line #4 of projects/  
\_contributors.html.erb:  
1:

  
2: \<% for contributor in @project.contributors %\>  
3: -   
4: \<% link\_to\_remote image\_tag(‘delete.png’, :size =\>  
‘16x16’, :alt =\> ‘Destroy’),  
5:  
delete\_contributor\_project\_path(params[:project\_id]),  
6: :method =\> :put, :contributor\_id =\>  
contributor.id %\>  
7: \<%= contributor.user.name %\>

```
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/

```

action\_controller/url\_rewriter.rb:102:in `rewrite_url' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/ action_controller/url_rewriter.rb:88:in`rewrite’  
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/  
action\_controller/base.rb:621:in `url_for' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/url_helper.rb:76:in`send’  
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_view/  
helpers/url\_helper.rb:76:in `url_for' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/prototype_helper.rb:461:in`remote\_function’  
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action\_view/  
helpers/prototype\_helper.rb:255:in `link_to_remote' app/views/projects/_contributors.html.erb:4:in`\_run\_erb\_47app47views47projects47\_contributors46html46erb’

changing link\_to\_remote by link\_to the partial renders fine, but  
that’s not what I want. What’s the problem using link\_to\_remote in  
this context?, Which is the missing object?, if @project was nil the  
error would be at line 2, but it isn’t.
