I''m working on a datepicker and a timepicker. The datepicker is the jQuery datepicker. The timepicker displays a drop down menu with available times. I want to have two different fields: the datepicker and timepicker. Then mix up the two (probably in the controller) and come up with the whole datetime data to be inserted into the database. The problem is, Rails doesn''t seem to let me create two different fields. <%= f.label :start_date %><br /> <%= f.text_field :start_time %> I get this error: Model Appointment does not respond to start_time And I understand, start_time doesn''t exist in the Model. So how can I create two fields in the form that don''t exist in the model (kinda like virtual columns) , then combine their two values and then insert the result into the database? Some of you may ask why don''t I just use the jQuery TimePicker, but I don''t like the time slider and I need to display only available times, so the jQuery TimePicker is out. Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Use the _tag versions of the form helpers. i.e., text_field_tag instead of f.text field. On Nov 30, 11:52 am, "Leonel *.*" <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m working on a datepicker and a timepicker. The datepicker is the > jQuery datepicker. The timepicker displays a drop down menu with > available times. > > I want to have two different fields: the datepicker and timepicker. Then > mix up the two (probably in the controller) and come up with the whole > datetime data to be inserted into the database. > > The problem is, Rails doesn''t seem to let me create two different > fields. > <%= f.label :start_date %><br /> > <%= f.text_field :start_time %> > > I get this error: > Model Appointment does not respond to start_time > > And I understand, start_time doesn''t exist in the Model. So how can I > create two fields in the form that don''t exist in the model (kinda like > virtual columns) , then combine their two values and then insert the > result into the database? > > Some of you may ask why don''t I just use the jQuery TimePicker, but I > don''t like the time slider and I need to display only available times, > so the jQuery TimePicker is out. > > Thanks > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Leonel *.* wrote in post #965158:> I''m working on a datepicker and a timepicker. The datepicker is the > jQuery datepicker. The timepicker displays a drop down menu with > available times. > > I want to have two different fields: the datepicker and timepicker. Then > mix up the two (probably in the controller) and come up with the whole > datetime data to be inserted into the database. > > The problem is, Rails doesn''t seem to let me create two different > fields. > <%= f.label :start_date %><br /> > <%= f.text_field :start_time %> > > I get this error: > Model Appointment does not respond to start_time > > And I understand, start_time doesn''t exist in the Model. So how can I > create two fields in the form that don''t exist in the model (kinda like > virtual columns) , then combine their two values and then insert the > result into the database?You''re asking the wrong question. Since you want a virtual attribute on the model, just create one with attr_accessor. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Leonel, Rails is (rightfully) telling you that those attributes of the model don''t exist yet. You said, "...then mix up the two (probably in the controller)..." That''s the part that is missing. How you do that is through virtual attributes (see Railscast #16 and #167) and done in the Model, not the Controller. I don''t think you don''t need to switch over to the _tag helpers for virtual attributes. Marnen, "You''re asking the wrong question," is rarely the right answer. Thanks for not stopping there. On Nov 30, 1:02 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Leonel *.* wrote in post #965158: > > > > > > > > > > > I''m working on a datepicker and a timepicker. The datepicker is the > > jQuery datepicker. The timepicker displays a drop down menu with > > available times. > > > I want to have two different fields: the datepicker and timepicker. Then > > mix up the two (probably in the controller) and come up with the whole > > datetime data to be inserted into the database. > > > The problem is, Rails doesn''t seem to let me create two different > > fields. > > <%= f.label :start_date %><br /> > > <%= f.text_field :start_time %> > > > I get this error: > > Model Appointment does not respond to start_time > > > And I understand, start_time doesn''t exist in the Model. So how can I > > create two fields in the form that don''t exist in the model (kinda like > > virtual columns) , then combine their two values and then insert the > > result into the database? > > You''re asking the wrong question. Since you want a virtual attribute on > the model, just create one with attr_accessor. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I was working on that two months ago and I thought I had everything figured out. But I stopped coding and now that I''m back I can''t remember what was my plan to do that. Thanks guys! I''ll try your suggestions. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.