# Nil object on post - but commit information is not empty?

**URL:** <https://www.ruby-forum.com/t/nil-object-on-post-but-commit-information-is-not-empty/123749>\
**Category:** Rails\
**Created:** [December 20, 2007, 9:35am UTC](https://www.ruby-forum.com/t/nil-object-on-post-but-commit-information-is-not-empty/123749 "2007-12-20T09:35:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kodama](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/439d5e/32.png) [@kodama](https://www.ruby-forum.com/u/kodama)\
**Post date:** [December 20, 2007, 9:35am UTC](https://www.ruby-forum.com/t/nil-object-on-post-but-commit-information-is-not-empty/123749/1 "2007-12-20T09:35:20Z")

</div>

Hello Rails folks,  
I am trying to roll my own widget and I’m having trouble when the data  
gets POSTed. My widget is basically three select boxes strung together  
to create one big string when the data gets submitted.

The TypeError message I get is “can’t convert nil into String” - but  
when I look at the parameters, they all appear to be defined. Maybe  
someone can enlighten me?

Here is the information:

app/controllers/calendar\_controller.rb:30:in `+' app/controllers/calendar_controller.rb:30:in`create’

Controller: the offending line in my ‘create’ method:

```
@event.start_time = params[:event_st][:st_hrs] +

```

params[:event\_st][:st\_mins] + params[:event\_st][:ampm]

View Code:

Start time  
\<%= select(:event\_st, :st\_hrs, hours) %\> \<%= select(:event\_st, :st\_mins, %w(00 15 30 45)) %\> \<%= select(:event\_st, :st\_ampm, %w(am pm)) %\>

The Model is called Event and doesn’t do anything special. But it has a  
“start\_time” attribute that I would like to write to.

Here is what is in the params when I hit “Create”:

Parameters: {“commit”=\>“Create”, “event”=\>{“end\_date(3i)”=\>“20”,  
“title”=\>“test”, “start\_date(1i)”=\>“2007”, “start\_date(2i)”=\>“12”,  
“start\_date(3i)”=\>“20”, “description”=\>“test”, “end\_date(1i)”=\>“2007”,  
“end\_date(2i)”=\>“12”, “end\_time”=\>“d”}, “event\_st”=\>{“st\_hrs”=\>“1”,  
“st\_ampm”=\>“am”, “st\_mins”=\>“00”}}

Any help would be greatly appreciated! I’ve spent a number of hours now  
digging around in the Rails API, my AWDWR book, Rails Recipes, but I  
couldn’t seem to find the information I was looking for on how to  
accomplish what I need.

Thanks,  
kodama

---

<div class="post-metadata">

**Author:** ![kodama](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/439d5e/32.png) [@kodama](https://www.ruby-forum.com/u/kodama)\
**Post date:** [December 20, 2007, 9:55am UTC](https://www.ruby-forum.com/t/nil-object-on-post-but-commit-information-is-not-empty/123749/2 "2007-12-20T09:55:12Z")

</div>

Hello,

I think your referencing the “ampm” parameter incorrectly. Try this:

@event.start\_time = params[:event\_st][:st\_hrs] + params[:event\_st]  
[:st\_mins] + params[:event\_st][:st\_ampm]

Cheers,  
Anthony

On Dec 20, 12:35 am, Old E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![kodama](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/439d5e/32.png) [@kodama](https://www.ruby-forum.com/u/kodama)\
**Post date:** [December 20, 2007, 7:57pm UTC](https://www.ruby-forum.com/t/nil-object-on-post-but-commit-information-is-not-empty/123749/3 "2007-12-20T19:57:47Z")

</div>

D’oh. That’ll teach me to read my code more carefully once I’m working  
past midnight. 🙂

Thanks a lot Anthony!

Anthony Franco wrote:

> Hello,
> 
> I think your referencing the “ampm” parameter incorrectly. Try this:
> 
> @event.start\_time = params[:event\_st][:st\_hrs] + params[:event\_st]  
> [:st\_mins] + params[:event\_st][:st\_ampm]
> 
> Cheers,  
> Anthony
> 
> On Dec 20, 12:35 am, Old E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
