I have a class called Appointment
that has, among other attributes, start_time
.
In my form, I'm not using start_time
directly. I'm separating it into start_time_time
(I know it's an awkward name) and start_time_ymd
. My goal is to combine start_time_ymd
and start_time_time
into a complete start_time
. (I'm doing this because I don't like the UI for the helper that comes with a date field.)
The error I'm getting is unknown attribute: start_time_time
, which is of course not surprising because Appointment
doesn't have any attribute called start_time_time
.
If start_time_time
were something from a related model, I could just do something like accepts_nested_attributes_for :whatever
, but since it's not, that wouldn't make sense.
How can I do what I'm trying to do? (I'm a Rails noob so you might have to spoon-feed开发者_开发技巧 it to me.)
I think using a virtual attribute (text version) is your best bet.
You could try this in your model:
attr_accessible :start_time_time, :start_time_ymd
精彩评论