开发者

"unknown attribute" error in nested form

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜