Forum: Rails Engines datebox_engine with multiple dateboxes on same form

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-02-17 01:54
(Received via mailing list)
I've got the datebox engine working fine if I just have one datebox on a
form.

It is a very nice little gui.

How do I configure it to handle multiple date boxes corresponding to
multiple table fields?

Thanks
Greg
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
00e3a96684ab390a350b0271e98741d3?d=identicon&s=25 Nshbrown Nshbrown (nshb)
on 2006-02-17 03:00
(Received via mailing list)
That feature hasn't been added yet.

I have a few emails outlining how someone did it, but haven't integrated
it
into a new version yet.

Feel free to submit patches, or example code how you manage to do it if
you
get around to it.

-Nb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Nathaniel S. H. Brown                           http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-02-17 20:04
(Received via mailing list)
Just realized I got ahead of myself.

I have reduced the databox's down to one on each of two forms.

They both appear to work from a gui perspective, but when I do a save
nothing changes in the DB.

Thus if I'm creating a new record the date field ends up blank.  If
I'm editing an exiting record, the date field remains unchanged.

Any idea what I'm doing wrong?

On 2/16/06, Nathaniel S. H. Brown <nshb@inimit.com> wrote:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Subject: [Engine-users] datebox_engine with multiple
> > Thanks
> >
>
> _______________________________________________
> engine-users mailing list
> engine-users@lists.rails-engines.org
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-02-18 01:44
(Received via mailing list)
On 2/16/06, Nathaniel S. H. Brown <nshb@inimit.com> wrote:
> That feature hasn't been added yet.
>
> I have a few emails outlining how someone did it, but haven't integrated it
> into a new version yet.
>
> Feel free to submit patches, or example code how you manage to do it if you
> get around to it.
>
> -Nb

I've got this working I think. I did NOT have to modify the engine.

I'm still fairly new with ruby/rails so I'm sure there are more
elegant ways to handle this.

In my partial view (_form.rhtml) I have:
<td><%= @date_field1=@table.date_field1
date_box('date_field1') %>
<td><%= @date_field2=@table.date_field2
date_box('date_field2') %>
<td><%= @date_field3=@table.date_field3
date_box('date_field3') %>

As you can see I'm creating 3 distinct instance variables initialized
from my table.  Then I'm passing the name of the instance variables
into date_box.

FYI: I tried directly passing in table.date_field1, but it croaked for
some reason I don't understand.

Question:  Is there a end of line character like ; in C to allow the
above to be on one line each?

With the above the existing unmodified engine causes the 3 new
instance variables to be available as params so in my controller I
updated my update and create methods to have:
@table.date_field1 = params[:date_field1]
@table.date_field2 = params[:date_field2]
@table.date_field3 = params[:date_field3]

The above is immediately after the table.find(params[:id])  line in
both the update and create methods.

I never did get the automatic database field updating feature to work
with even a single date.  For someone that has that feature working
maybe they could eliminate having to add the extra lines to the update
method.

HTH
Greg
--
Greg Freemyer
77a63e1e894d85ec1b9cf76e2dade75b?d=identicon&s=25 Josh Adams (Guest)
on 2006-02-24 01:59
You can always just use a ; to separate Ruby statements...
>
> Question:  Is there a end of line character like ; in C to allow the
> above to be on one line each?
This topic is locked and can not be replied to.