LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Rails: no path for link_to (https://www.linuxquestions.org/questions/programming-9/rails-no-path-for-link_to-817275/)

CoderMan 06-30-2010 08:29 PM

Rails: no path for link_to
 
I'm still going through "Agile Web Development with Rails" (Beta version), and I'm confused as to why some code in the book is not working for me. Following their example code in the book, I created code like so:

Code:

$ rails demo
# ...
$ cd demo/
$ script/generate controller Say index hello goodbye
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/say
      exists  test/functional/
      create  test/unit/helpers/
      create  app/controllers/say_controller.rb
      create  test/functional/say_controller_test.rb
      create  app/helpers/say_helper.rb
      create  test/unit/helpers/say_helper_test.rb
      create  app/views/say/index.html.erb
      create  app/views/say/hello.html.erb
      create  app/views/say/goodbye.html.erb

After starting the server, I can view the index view and the other views just fine. But then I have trouble if I add this code to any of the view html templates:

Code:

<p><%= link_to "Hello", say_hello_path %></p>
I'm told this is supposed to generate a link to the say/hello view. But instead I get an error message like so:

Code:

undefined local variable or method `say_hello_path' for #<ActionView::Base:0xb6ce3090>
If I edit it to

Code:

<p><%= link_to "Hello", Say_hello_path %></p>
then I get

Code:

uninitialized constant ActionView::Base::CompiledTemplates::Say_hello_path
But I haven't noticed anything in the book so far indicating that I am supposed to initialize these constants or how I am supposed to do it. Where have I gone wrong here...?

CoderMan 07-01-2010 03:44 PM

I found the answer (more or less) at another forum. Including the link for posterity:

http://railsforum.com/viewtopic.php?id=39774


All times are GMT -5. The time now is 06:59 AM.