bparanj
1
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:
Click on a composer’s name
3: to see all of that composer’s works.
4:
5: <% @composers.each do |composer| %>
6: - <%= link_to “#{composer.first_name} #{composer.last_name}”,
7: :controller => “composer”,
8: :action => “show”,
bparanj
2
Bala P. ïèøåò:
You might have expected an instance of Array.
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
bparanj
3
You are right, welcome method was empty. Thank you.
bparanj
4
Sorry, it was 2pm at night (I posted it just before I went to sleep)
bparanj
5
Bala P. 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
All the Best!
Sergey.
bparanj
6
rub on rails…
sounds kind of relaxing.
On 9/28/06, Bala P. [email protected] wrote:
–
Ross R.
www.sorrylies.com
bparanj
8
Oops, I did it again. All right it was 2am in the
morning.
Are ya’ll satisfied now?