Forum: Ruby on Rails The error occurred while evaluating nil.to_sym

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Guillermo A. (Guest)
on 2008-09-12 17:56
(Received via mailing list)
Hello guys,

I've been developing in Ruby for a few months and I am starting to
work with Rails. I am having a problem right from the start and I
think I am not doing anything wrong. I have performed the following
steps:

1. run rails test
2. run script/server and it works perfectly connecting to the database
without problems (sqllite)
5. run script/generate scaffold release_notes title:string
version:string content:text
6. rake db:migrate
7. shutdown the server and start it again
8. http://localhost:3000/release_notes/new and it works just fine
9. After I click on create I get the error below.  I have checked that
removing all the "link_to" entries the error disappear. any ideas?
what am I forgetting?

NoMethodError in Release_notes#index
Showing release_notes/index.html.erb where line #15 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym


Extracted source (around line #15):

12:     <td><%=h release_notes.title %></td>
13:     <td><%=h release_notes.version %></td>
14:     <td><%=h release_notes.content %></td>
15:     <td><%= link_to 'Show', release_notes %></td>
16:     <td><%= link_to 'Edit', edit_release_notes_path(release_notes)
%></td>
17:     <td><%= link_to 'Destroy', release_notes, :confirm => 'Are you
sure?', :method => :delete %></td>
18:   </tr>




RAILS_ROOT: /Users/gacilu/Knowledge Administration/Koiaka Project/
Projects/F1/Development/Iteration4/code/iqserver

Application Trace | Framework Trace | Full Trace
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/routing/route.rb:145:in `extra_keys'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/routing/route.rb:145:in `map'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/routing/route.rb:145:in `extra_keys'
generated code (/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/
actionpack-2.1.1/lib/action_controller/routing/route.rb:45):3:in
`generate'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/routing/route.rb:122:in `generate'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/routing/route_set.rb:337:in `generate'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/url_rewriter.rb:131:in `rewrite_path'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/url_rewriter.rb:110:in `rewrite_url'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/url_rewriter.rb:88:in `rewrite'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_controller/base.rb:622:in `url_for'
/usr/local/jruby-1.1.4/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/
action_view/helpers/url_helper.rb:71:in `url_for'
(eval):17:in `release_notes_path'
app/views/release_notes/index.html.erb:15:in
`_run_erb_47app47views47release_notes47index46html46erb'
app/views/release_notes/index.html.erb:10:in `each'
app/views/release_notes/index.html.erb:10:in
`_run_erb_47app47views47release_notes47index46html46erb'
app/controllers/release_notes_controller.rb:7:in `index'
:1:in `initialize'

Thanks,

GA
Thorsten M. (Guest)
on 2008-09-12 18:09
(Received via mailing list)
this should have a path
<%= link_to 'Show', release_notes %></td>
like
<%= link_to 'Show', release_note_path(release_notes) %></td>
or whatever you defined in your routes
Guillermo A. (Guest)
on 2008-09-12 18:28
(Received via mailing list)
Thanks for your answer.
I have not defined anything in the routes yet. If I did not do any
changes,
shouldn't the generated file work from the beginning?

GA
Benoit M. (Guest)
on 2009-06-15 03:36
I have the same probleme, but the route is setted :
"map.ressources :myaction"

First all methods *_action_path don't work (unknow by RoR) but they were
created by scaffolding so it's supposed to exist ??

And if I use the trick "release_note_path(release_notes)" instead of
just use linkto the object, I have this f***cking error too :
"You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym"

I just found a topic talking about it
(http://www.hostingrails.com/1029/undefined-method-...)
but the guy seems to give up and put all links without linkto. But for
my apps the probleme is every where and not just for one action.

Really strange ...
bill walton (Guest)
on 2009-06-15 06:32
(Received via mailing list)
Hi Benoit,

On Mon, 2009-06-15 at 01:36 +0200, Benoit M. wrote:
> I have the same probleme, but the route is setted :
> "map.ressources :myaction"

You sure the spelling error above hasn't found its way into your code?

Best regards,
Bill
Sijo k. (Guest)
on 2009-06-15 09:45
> 5. run script/generate scaffold release_notes title:string
> version:string content:text

  Try like
./script/generate scaffold ReleaseNote title:string version:string
content:text
Benoit M. (Guest)
on 2009-06-15 13:13
I have to stop drugs really ...
Last night I used something like ./script/generate scaffold nameS ...
If I put an S on the scaffold name, every thing is weel generated except
the model who take an 'S'. I suppose that's why RoR failed so badly.

But it's strange because 'controller'_path was working instead of
edit_'controller'_path and delete_'controller'_path were unknew by RoR.

Anyway, thank you for the help. I were not able to find this 'S' by my
self.
This topic is locked and can not be replied to.