# Question regarding a model

**URL:** <https://www.ruby-forum.com/t/question-regarding-a-model/122610>\
**Category:** Rails\
**Created:** [December 10, 2007, 4:08am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610 "2007-12-10T04:08:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 10, 2007, 4:08am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610/1 "2007-12-10T04:08:24Z")

</div>

I have model named Test\_session and am trying to add data to it. I have  
always been in the situation where I have the user fill out a form and  
then create a new entry in a table. This time I am trying to save  
sessions of a test where the session has the users id and group they  
belong to. I tried doing the following…

@test\_session = Test\_session.new() or Test\_session.new \<— I tried  
them both  
@test\_session.user\_id = session[:user\_id]  
@test\_session.group = session[:group]  
@test\_session.save

I get the following error…

Expected /app/models/test\_session.rb to define Test\_session

Like i said normally I use something on the lines of… @test\_session =  
Test\_session.new(params[:test\_session]) where the params comes from a  
form. How can you create a new entry in the database without a form and  
then set the two fields based of of two values stored in a session

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 10, 2007, 4:11am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610/2 "2007-12-10T04:11:19Z")

</div>

The file does exists and the .rb files for a few other models are also  
empty and they work fine… although the entried are filled out through  
a form

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 10, 2007, 4:17am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610/3 "2007-12-10T04:17:54Z")

</div>

Ryan B. wrote:

> Can you show us the code from test\_session.rb? At a guess it’s  
> TestSession  
> and not Test\_session.

Thanks a lot… my naming was wrong. The file is called test\_session.rb  
but when you open the file the class is TestSession. I always thought  
it was good to use \_ in ruby. Maybe just the wrong case here.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 10, 2007, 4:37am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610/4 "2007-12-10T04:37:57Z")

</div>

Ideally you shouldn’t have underscores in class names anyway; They  
should  
always be CamelCase.

On Dec 10, 2007 1:47 PM, Hickman H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [December 10, 2007, 4:13am UTC](https://www.ruby-forum.com/t/question-regarding-a-model/122610/5 "2007-12-10T04:13:23Z")

</div>

Can you show us the code from test\_session.rb? At a guess it’s  
TestSession  
and not Test\_session.

On Dec 10, 2007 1:41 PM, Hickman H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The file does exists and the .rb files for a few other models are also  
> empty and they work fine… although the entried are filled out through  
> a form
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!
