Link_to_remote object missing

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 %>
  • <% link_to_remote image_tag('delete.png', :size => '16x16', :alt => 'Destroy'),

    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:inrewrite’
    /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:insend’
    /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:inremote_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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs