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: <p><label for="event_start_time">Start time</label><br/> <!-- hours is a helper method that returns an array of numbers--> <%= 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anthony Franco
2007-Dec-20 08:54 UTC
Re: nil object on post - but commit information is not empty?
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 Echo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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: > > <p><label for="event_start_time">Start time</label><br/> > <!-- hours is a helper method that returns an array of numbers--> > <%= 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 > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Old Echo
2007-Dec-20 18:57 UTC
Re: nil object on post - but commit information is not empty?
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 Echo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---