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",
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