Ruby on Rails - assignment of multiparameter and attr_accessor and 12_hour_time

Okay, I slowly figure it out, but I need more help.

I use time_select in my opinion, so I deal with multi-parameter assignment. Check it out.

<%= pt.time_select :time, :twelve_hour => true, :minute_step => 5 %>

BUT I do a naughty thing and use it with an attribute that is not in the database:

attr_accessor time

Therefore, since it cannot look at db, it cannot compose what should be assigned by the multiparameter, and therefore I get the following error:

1 error(s) on assignment of multiparameter attributes

Thus, I use the information I found here :

  composed_of :time,
            :class_name => 'DateTime',
            :mapping => [%w(DateTime to_s)],
            :constructor => Proc.new{ |item| item },
            :converter => Proc.new{ |item| item }

Other useful links: rubyonrails.org | apidock.com

, , , , , . http://code.google.com/p/rails-twelve-hour-time-plugin/. , , 3 : hh: mm am/pm.

, , composed_of method, ? ?

, mappers// . , , , 24 ( , ).

+3
1

, . .

  composed_of :time,
            :class_name => 'Time',
            :mapping => [%w(Time to_s)],
            :constructor => Proc.new{ |item| item },
            :converter => Proc.new{ |item| item }

, . . . :

class Whatever < ActiveRecord::Base
  ...

  attr_accessor :arrival_time
  columns_hash["arrival_time"] = ActiveRecord::ConnectionAdapters::Column.new("arrival_time", nil, "time")
end

, , - .

+5

All Articles