views:

75

answers:

1

I am facing this strange problem with the following section of code

<% if (@more == -1) %>
  <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%>
<% else %>
  <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => @more.to_i + 1} , :html => {:id => 'more-link'} %>
<% end %>

Now when I use this code, I get the following error

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.[]

Also the error seems to be at this line.

  <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%>

So cant really figure out why this is not working?

+1  A: 

on line 4, look at

'view' ,:id

(move your comma over) also I'm thinking you would need a :url hash on line 2 as well

tybro0103
Yeah that worked i added a :url hash on line 2, surprisingly it works well in rails 2.3.4. Thanks!!!
Shiv
yes, I haven't actually looked the documentation but I'd imagine it requires a url since it is a link after all
tybro0103