# Creating variable

**URL:** <https://www.ruby-forum.com/t/creating-variable/196569>\
**Category:** Rails\
**Created:** [January 13, 2008, 10:26am UTC](https://www.ruby-forum.com/t/creating-variable/196569 "2008-01-13T10:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [January 13, 2008, 10:26am UTC](https://www.ruby-forum.com/t/creating-variable/196569/1 "2008-01-13T10:26:53Z")

</div>

Good morning,

I am beginning to develop a ruby part of a web. I  
I have the driver code “book” and I spend their ID in the variable  
Book.current\_book.id, but gives me the following error.

undefined method `current\_book’ for Book:Class

How do I define the variable to my tests?

Thank you

---

<div class="post-metadata">

**Author:** ![zaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e95f7d/32.png) [@zaid](https://www.ruby-forum.com/u/zaid)\
**Post date:** [January 13, 2008, 2:05pm UTC](https://www.ruby-forum.com/t/creating-variable/196569/2 "2008-01-13T14:05:46Z")

</div>

On 13 Jan 2008, at 09:26, Davicín … wrote:

> Good morning,
> 
> I am beginning to develop a ruby part of a web. I  
> I have the driver code “book” and I spend their ID in the variable  
> Book.current\_book.id, but gives me the following error.
> 
> undefined method `current\_book’ for Book:Class
> 
> How do I define the variable to my tests?  
> You’ll have to show us exactly what it is you are doing/trying to do.

Fred
