Rub on Rails Question

I am getting the following error when I point the browser to http://localhost:3000

I have checked the composers table and it has two records. Can someone please help me to fix this problem? TIA

NoMethodError in Main#welcome

Showing app/views/main/welcome.rhtml where line #5 raised:

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 #5):

2: <p>Click on a composer's name 3: to see all of that composer's works.</p> 4: <ul> 5: <% @composers.each do |composer| %> 6: <li><%= link_to "#{composer.first_name} #{composer.last_name}", 7: :controller => "composer", 8: :action => "show",

Bala Paranj пишет:

I am getting the following error when I point the browser to http://localhost:3000

I have checked the composers table and it has two records. Can someone please help me to fix this problem? TIA NoMethodError in Main#welcome

Showing app/views/main/welcome.rhtml where line #5 raised:

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 #5):

2: <p>Click on a composer's name 3: to see all of that composer's works.</p> 4: <ul> 5: <% @composers.each do |composer| %> 6: <li><%= link_to "#{composer.first_name} #{composer.last_name}", 7: :controller => "composer", 8: :action => "show",

You should have prepared that array (@composers) in controllers "welcome" method:

app/controllers/main_controller.rb class MainController < ApplicationController   def welcome     @composers = Composer.find(:all)   end end

You are right, welcome method was empty. Thank you.

rub on rails..... sounds kind of relaxing. :wink:

Sorry, it was 2pm at night (I posted it just before I went to sleep)

Bala Paranj wrote:

Sorry, it was 2pm at night (I posted it just before I went to sleep)   

2pm at night is even more relaxing, but management do not allows me to sleep at that time :slight_smile:

All the Best! Sergey.

Oops, I did it again. <Seinfield Tone On> All right it was 2am in the morning.<Seinfield Tone Off> Are ya'll satisfied now?

Bala Paranj wrote:

Oops, I did it again. <Seinfield Tone On> All right it was 2am in the morning.<Seinfield Tone Off> Are ya'll satisfied now?   

More then. :slight_smile: