Ruby on rails error

The error and code is below. Any help would be greatly appreciated.

Error is

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each

Extracted source (around line #6):

3:


4:
5: <% x = 0 %>
6: <% for video in @videos %>
7:
<%= link_to(image_tag(“videos/#{video.video_thumbnail}”,
8: :size => ‘132x99’,
9: :border => 5,

Controller is

def selectaction
@video = Video.find :all
end

View is

<% x = 0 %> <% for video in @videos %> " %> <% else %> <%= "" %> <% end %> <% end %>
<%= link_to(image_tag("videos/#{video.video_thumbnail}", :size => '132x99', :border => 5, :id => 'thumbnail'), url_for(:action => 'show', :id => video) ) %>
Title: <%= h video.title %>
Host: <%= h video.username %>
Views: <%= h video.views %>
Skill Level: <%= h video.rating %>/10
<% x = x + 1 %> <% if x % 2 == 0 %> <%= "

<%= link_to ‘Previous page’, { :page => @video_pages.current.previous }
if @video_pages.current.previous %>
<%= link_to ‘Next page’, { :page => @video_pages.current.next } if
@video_pages.current.next %>


<%= link_to ‘New video’, :action => ‘new’ %>

Jack Arnst wrote:

The error and code is below. Any help would be greatly appreciated.

Error is

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each

Extracted source (around line #6):

3:


4:
5: <% x = 0 %>
6: <% for video in @videos %>
7:
<%= link_to(image_tag(“videos/#{video.video_thumbnail}”,
8: :size => ‘132x99’,
9: :border => 5,

Controller is

def selectaction
@video = Video.find :all
end

Jack,

Next time, please use the rails forum for posting rails related issues.

In this particular case, the instance variable in your controller is
@video” while the variable you are trying to access in your view is
@videos”. Change the name in your controller and everything should be
ok.

Hope this helps

ilan