# Unable to get past Tutorial 1 in RubyOnRails

**URL:** <https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573>\
**Category:** Rails\
**Created:** [May 7, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573 "2006-05-07T19:16:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 7, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/1 "2006-05-07T19:16:58Z")

</div>

Unable to get past Tutorial 1 in RubyOnRails

On 29 April 2006 I met some one in a Microsoft sponsored developersâ??  
community gahering. I was told that ruby on rails is a free software,  
easy to use, and in no time will have my mind blown with all the  
wonderful prospects and possibilities.

After almost a week, I am still unable to get past tutorial 1 and still  
unable to make any tutorials work so far.

I have watched a few videos and demos from the web and I have browsed  
through half a book on programming ruby.

I have tried

> **[Radar - O’Reilly](https://www.oreilly.com/radar/?page=1)**
>
> Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

Encountered some problems such as â??Port 80 for Apache was being used by  
some other processâ?, and being unable to connect to my mySql in the  
local host.

So I switched to a newer version of the tutorial in  
[http://instantrails.rubyforge.org/tutorial/index.html](http://instantrails.rubyforge.org/tutorial/index.html)  
I encountered similar problems.

So, I moved on to try the tutorial in the site  
[http://rails.homelinux.org/](http://rails.homelinux.org/) for 4 days on rails.  
I couldnâ??t even get into day 1, so to say.

I also tried the tutorial on  
[http://wiki.rubyonrails.org/rails/pages/Tutorial](http://wiki.rubyonrails.org/rails/pages/Tutorial) and didnâ??t get to point  
of â??Congratulations, youâ??re on Rails!â?  
I browsed through the 6 part tutorials, but didnâ??t gained much.  
After that I went back to  
[http://instantrails.rubyforge.org/tutorial/index.html](http://instantrails.rubyforge.org/tutorial/index.html)  
Un-installed and re-installed a few times until I came to the part where  
â??Editâ? a recipe was introduced and got stuck.

So, I turned to the Forum for help, stating my problem as best I could.

I was advised to look at the codes in the pre-installed â??cookbookâ?. I  
went through the processes and found that each of the step work.

Since the â??Editâ? part didnâ??t work in my exercise in â??cookbook2â?, I  
copied the whole folder â??Appâ? from â??cookbookâ? to â??cookbook2â? so the  
codes are idential.

I removed the database â??cookcook2â? and used the MySQL-Front 3.2 to  
create a new database â??cookbook2â? and check to make sure that the tables  
and fields resembled those of the pre-installed â??cookbookâ?.

I was able to log into the website to create the required categories so  
that they wouldnâ??t be empty when I tried to create new recipes.

Some one please help!

I was able to to enter the website to create a new recipe, using  
[http://localhost:3000/recipe/new](http://localhost:3000/recipe/new)

Problem came when I pressed to â??Createâ? button.

This brought me to the url: [http://localhost:3000/recipe/list](http://localhost:3000/recipe/list)

Error message:  
NoMethodError in Recipe#list  
Showing app/views/recipe/list.rhtml where line #23 raised:  
You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.name  
Extracted source (around line #23):  
20:   
21:   
22:   
23: \<%= link\_to recipe.category.name,  
24: :action =\> “list”,  
25: :category =\> “#{recipe.category.name}” %\>  
26:   
RAILS\_ROOT: ./script/…/config/…  
Application Trace | Framework Trace | Full Trace  
#{RAILS\_ROOT}/app/views/recipe/list.rhtml:23  
#{RAILS\_ROOT}/app/views/recipe/list.rhtml:8  
Request  
Parameters: None  
Show session dump  
Response  
Headers: {“cookie”=\>[], “Cache-Control”=\>“no-cache”}

---

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 7, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/2 "2006-05-07T20:25:56Z")

</div>

the error basically means that the category is nil (i.e.  
cookbook.nil.name)

hope this helps.

---

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 8, 2006, 5:32am UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/3 "2006-05-08T05:32:30Z")

</div>

Yes, this is correct. Go look at your recipes table and make sure that  
every  
recipe has an assigned category.

Curt

---

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 8, 2006, 7:19am UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/4 "2006-05-08T07:19:43Z")

</div>

Curt H. wrote:

> Yes, this is correct. Go look at your recipes table and make sure that  
> every  
> recipe has an assigned category.
> 
> Curt

Hi, All

I found my mistake in the database setting.

The field “title” in the table [recipes] doesnot allow null and I set  
the default to [null].

Once I corrected this mistake, the application is running.

Thanks for your advice that led me me to discover the mistake.

Now, I can proceed to a new tutorial.

Regards,

Ling.

---

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 8, 2006, 5:34am UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/5 "2006-05-08T05:34:27Z")

</div>

Greetings.

Thanks for the reply. At this stage I still donâ??t know enough of the  
syntax of ruby. Even though I have guessed that it means category or  
recipe is nil, I still donâ??t know how to resolve the problem.

What puzzles me is that the codes work in â??cookbookâ? but not in  
â??cookbook2â?.

The same problem occurred when I tried to show the list of recipes when  
there were none. Isnâ??t it possible to display an empty list in ruby?

Can some one help? Or do I need to finish reading the book â??Programming  
in rubyâ? before I can work the tutorial 1?

Regards,

Ling.

The codes behind the module â??list.rhtmlâ? is repordued as follows:

\<% @recipes.each do |recipe| %\>  
\<% if (@category == nil) || (@category == recipe.category.name)%\>

  

| 

_ **Recipe** _

 | 

_ **Category** _

 | 

_ **Date** _

 |
|   
\<%= link\_to recipe.title,  
:action =\> “show”,  
:id =\> recipe.id %\>  

```
    <%= link_to "(delete)",
                {:action => "delete", :id => recipe.id},
                :confirm => "Really delete #{recipe.title}?" %>
    </font>
  </td>
  <td>
    <%= link_to recipe.category.name,
                :action => "list",
                :category => "#{recipe.category.name}" %>
  </td>
  <td><%= recipe.date %></td>
 </tr>

```

\<% end %\>  
\<% end %\>

 |

cyx wrote:

> the error basically means that the category is nil (i.e.  
> cookbook.nil.name)
> 
> hope this helps.

---

<div class="post-metadata">

**Author:** ![Ling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c2a13f/32.png) [@Ling](https://www.ruby-forum.com/u/Ling)\
**Post date:** [May 8, 2006, 5:41am UTC](https://www.ruby-forum.com/t/unable-to-get-past-tutorial-1-in-rubyonrails/94573/6 "2006-05-08T05:41:57Z")

</div>

Thanks. Curt.

I have created 3 categories before I tried to create the first recipe.

I chose a category from the drop down. So there was a category for the  
new recipe to be created.

It appears that the recipe list was empty up till then.

When I pressed the “Create” button, the error message as shown appeared.

The same message appeared when I tried to display the recipes when there  
were none.

So, what is the problem?

Regards,

Ling

Curt H. wrote:

> Yes, this is correct. Go look at your recipes table and make sure that  
> every  
> recipe has an assigned category.
> 
> Curt
