Forum: Ruby on Rails dynarch calendar and calendar helper usage

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.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-10 04:57
(Received via mailing list)
I am playing around with this and reference this wiki from RonR site...

http://wiki.rubyonrails.org/rails/pages/CalendarHelper

The error I am getting is:

NameError in Placements#list
undefined local variable or method `date_format' for
#<PlacementsController:0xb78f9ef4>

RAILS_ROOT: script/../config/..

Application Trace | Framework Trace | Full Trace
./script/../config/../app/controllers/application.rb:9:in `localize'

Makes sense... the lines in application.rb are:

  prepend_before_filter :localize

  def localize
    # determine locale and set other relevant stuff
    ActiveRecord::Base.date_format = date_format
  end

I'm not entirely clear on where to put the other sections...

#1
ActiveRecord::Base.class_eval do
  include BoilerPlate::Model::I18n
end

#2
require 'active_record'
require 'date'

module BoilerPlate # :nodoc:
  module Model # :nodoc:
  ...

and it seemed obvious to me that the first large section of code on that
wiki goes directly into the application controller that will be using
it.

I have tried putting the sections labeled #1 & #2 both in application.rb
and in my specific controller but that doesn't seem to satisfy the
'localize' thing.

Evidently, I am missing something of significance...clues anyone?

Thanks

Craig
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-10 05:37
(Received via mailing list)
On Thu, 2006-02-09 at 20:57 -0700, Craig White wrote:
> RAILS_ROOT: script/../config/..
>     ActiveRecord::Base.date_format = date_format
> require 'active_record'
> Evidently, I am missing something of significance...clues anyone?
----
and while I am at this - which I still can't figure out...

if I make changes to application.rb

do I have stop/start webrick again?

Craig
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2006-02-10 06:08
(Received via mailing list)
As far as changing application.rb goes, I think you need to stop/start
Webrick only if you make structural changes (e.g. add a new method,
add a new :before_filter).  If you simply e.g. change code within an
existing method, but don't rename/add/delete any methods or tweak
filters, you don't seem to need to restart Webrick.

That's from trial and error - I haven't looked into it closely
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-10 07:26
(Received via mailing list)
On Thu, 2006-02-09 at 21:37 -0700, Craig White wrote:
> On Thu, 2006-02-09 at 20:57 -0700, Craig White wrote:
> > I am playing around with this and reference this wiki from RonR site...
> >
> > http://wiki.rubyonrails.org/rails/pages/CalendarHelper
> >
----
I'm still confused on this...

can someone look at this link above and tell me (should be easy for
someone who's familiar with rails...)

there are 4 sections of code in grey on this page.

The first section obviously goes into my controller.

The 4th section apparently goes into application.rb (but it is the one
that generates an error)

I am trying to figure out where sections 2 & 3 go and I can't make it
work and I've mainly trying the appropriate model and application.rb

The error that I get (caused by section 4) is...

NameError in Placements#list
undefined local variable or method `date_format' for
#<PlacementsController:0xb78f9ef4>

RAILS_ROOT: script/../config/..

Application Trace | Framework Trace | Full Trace
./script/../config/../app/controllers/application.rb:9:in `localize'

Craig
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-10 22:57
(Received via mailing list)
On Thu, 2006-02-09 at 23:25 -0700, Craig White wrote:
> someone who's familiar with rails...)
>
----
In tracking all this down...it appears to me that this requires some
code that has to be had from the poster's own web site to become
operational and I can't justify it at this point.

I can't stand the 'date_select' widget as it is way too clumsy for a
form that has 8 different dates to input and I really want a widget
selector as hand entered data is messy.

Are there any other 'gem' type date selection widgets that I could have
a reasonable expectation not to break in the next ruby/rails release?

Craig
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-11 02:43
(Received via mailing list)
On Fri, 2006-02-10 at 14:57 -0700, Craig White wrote:
> > can someone look at this link above and tell me (should be easy for
>
> Are there any other 'gem' type date selection widgets that I could have
> a reasonable expectation not to break in the next ruby/rails release?
>
---
OK - I moved on to 'Date Picker'

http://wiki.rubyonrails.org/rails/pages/DatePicker

very very nice and almost completely working. The only thing that
doesn't work is if there is a date existing in the field, it won't
display but rather gives the pre-defined prompt for a blank value.

the code in my view looks like this...

<%= hidden_field 'placement', 'intake_date',
  :display_value => 'placement_intake_date' %>

and it's 'display_value' that is important.
(placement is my table/intake_date is the column)

According to the rendered html in my browser, the source looks like
this...

<input display_value="placement_intake_date"
  id="placement_intake_date" name="placement[intake_date]"
  type="hidden"
  value="2006-02-10" />

I have been adjusting and adjusting my <%= hidden_field entry but cannot
come up with the right juju to make :display_value => #whatever#

I have tried (going from recall)
'placement_intake_date'
'placement.intake_date'
[placement][intake_date]
['placement']['intake_date']
[:placement][:intake_date]
and many more...I'm dizzy now

The javascript code pops up correctly, picks a date correctly, displays
on screen after it has been picked correctly, writes it back to table
correctly but simply doesn't display the already entered value for the
field upon page first load...which is gonna confuse users.

Anyone with juju that I obviously lack?

Craig
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-02-11 05:28
(Received via mailing list)
Craig - try Duane Johnsons's bundled_resources. Couldn't be easier
Eric.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-11 05:54
(Received via mailing list)
Hey thanks - I saw that and really didn't want to do that.

The application that I am working on is for a non-profit mental health
facility and it has to be durable and I simply don't want to take a
chance on non-standard code that might get abandoned or obsoleted by new
versions of ruby/rails if I can help it.

I did get Date Picker fully function and it's really nice - I do plan on
creating an account and fixing up his wiki page that describes it since
he includes an html page but not any rhtml which makes usage clear and
drug addled brains (I am after all a child of the 60's) are gonna
struggle with it.

It is way cool - beats the date_select widgets to all hell and really
should become fully integrated into rails code. The dynarch calendar
does create a stickier problem with its LGPL license anyway.

Side note to Estelle - bring it on...I can help you through the calendar
widget.

Craig
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-02-11 07:34
(Received via mailing list)
Craig White wrote:
> drug addled brains (I am after all a child of the 60's) are gonna
>
> On Sat, 2006-02-11 at 15:27 +1100, Eric Sloane wrote:
>
>>Craig - try Duane Johnsons's bundled_resources. Couldn't be easier
>>Eric.
>>
>>Craig White wrote:
>>
> which makes usage clear and
> drug addled brains (I am after all a child of the 60's) are gonna
> struggle with it.


You and me both => matter of fact today is my 60th birthday. And we all
thought we'd never get past 30, hey, hey, my, my. And as for drug addled
- tonights the night, LOL
Cheers,
Eric.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-11 07:40
(Received via mailing list)
On Sat, 2006-02-11 at 17:33 +1100, Eric Sloane wrote:
> You and me both => matter of fact today is my 60th birthday. And we
> all
> thought we'd never get past 30, hey, hey, my, my.
----
heck - my dad told me that I was never gonna see my 18th birthday.

;-)

Happy birthday dude

Craig
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-02-11 08:06
(Received via mailing list)
LOL - I tell my kids that too
A9cdc0b24a1ee497ad749afab0ec5c30?d=identicon&s=25 Luigi Rizzo (luigi)
on 2006-04-07 16:05
(Received via mailing list)
Hello Craig. I'm after the some issue of yours in using the Date Picker.
Had you any luck in solving this one? Would you like to share it?
Thanks.

P.S. Also, I'm not able to use the "date_picker_field" form. Any hints
for this too?

On 2/11/06, Craig White <craigwhite@azapple.com> wrote:
> very very nice and almost completely working. The only thing that
> doesn't work is if there is a date existing in the field, it won't
> display but rather gives the pre-defined prompt for a blank value.

The javascript code pops up correctly, picks a date correctly, displays
on screen after it has been picked correctly, writes it back to table
correctly but simply doesn't display the already entered value for the
field upon page first load...which is gonna confuse users.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-04-07 17:13
(Received via mailing list)
On Fri, 2006-04-07 at 16:02 +0200, Luigi Rizzo wrote:
>
> The javascript code pops up correctly, picks a date correctly, displays
> on screen after it has been picked correctly, writes it back to table
> correctly but simply doesn't display the already entered value for the
> field upon page first load...which is gonna confuse users.
----
I got date_picker to work just fine...was relatively easy.

What isn't working on date_picker?

Craig
46710a442003bd7f8e0100b41e4cfe7c?d=identicon&s=25 Maurizio Balestrieri (Guest)
on 2006-04-07 18:05
(Received via mailing list)
On 4/7/06, Craig White <craigwhite@azapple.com> wrote:
> What isn't working on date_picker?

I've been able to recall the original value of the data field
("due_date") and make it the link to trigger the popup calendar.

<input type="hidden" id="task[due_date]" name="task[due_date]"
size="10" value="" />
<a id="_due_date_link" href="#"
onclick="DatePicker.toggleDatePicker('due_date')"
class="demo_link"><%= @task.due_date.strftime("%d/%m/%y") %></a>
<div id="_due_date_calendar" class="date_picker"
style="display:none"></div>

And when I change the due_date the changes are correctly written back
into the database.
The problem is when I do not change the date (I change other fields in
the form) and when I update the form content the data could not be
written because I've a not-null clause in the database field and the
date committed back seems to be null and thus the "update" could not
happen (see the rror below):

SQLite3::SQLException: tasks.due_date may not be NULL: UPDATE tasks
SET "due_date" = NULL, "show_due_date" = 1, "state_id" = 1, "notes" =
'', "updated_on" = '2006-04-07 18:04:01', "body" = 'Compilare
documenti assegnazione incarico', "isdone" = 0, "priority" = NULL,
"created_on" = '2006-04-04 17:01:28' WHERE id = 6

I'm not sure if I've been clear enough in describing the problem ...
but let's take it as a first cut. :)
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-04-07 18:57
(Received via mailing list)
On Fri, 2006-04-07 at 18:04 +0200, Maurizio Balestrieri wrote:
> class="demo_link"><%= @task.due_date.strftime("%d/%m/%y") %></a>
> SQLite3::SQLException: tasks.due_date may not be NULL: UPDATE tasks
> SET "due_date" = NULL, "show_due_date" = 1, "state_id" = 1, "notes" =
> '', "updated_on" = '2006-04-07 18:04:01', "body" = 'Compilare
> documenti assegnazione incarico', "isdone" = 0, "priority" = NULL,
> "created_on" = '2006-04-04 17:01:28' WHERE id = 6
>
> I'm not sure if I've been clear enough in describing the problem ...
> but let's take it as a first cut. :)
----
No, I think I understand...

<input type="hidden" id="task[due_date]"
 name="task[due_date]" size="10" value="" />
<a id="_due_date_link" href="#"
 onclick="DatePicker.toggleDatePicker('due_date')"
 class="demo_link"><%= @task.due_date %></a>
<div id="_due_date_calendar" class="date_picker"
style="display:none"></div>

I think that your problem is the conversion to strftime - try taking it
out (as I have done above) and see if that prevents the problem. If that
is the case, put your conversion back in the view but convert it back
within the 'update' method before the save.

Craig
This topic is locked and can not be replied to.