Dynarch calendar and calendar helper usage


#1

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


#2

On Thu, 2006-02-09 at 20:57 -0700, Craig W. 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


#3

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


#4

On Thu, 2006-02-09 at 23:25 -0700, Craig W. 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


#5

On Fri, 2006-02-10 at 14:57 -0700, Craig W. 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…

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


#6

Craig - try Duane J.s’s bundled_resources. Couldn’t be easier
Eric.


#7

On Thu, 2006-02-09 at 21:37 -0700, Craig W. wrote:

On Thu, 2006-02-09 at 20:57 -0700, Craig W. 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


#8

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


#9

Craig W. 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 S. wrote:

Craig - try Duane J.s’s bundled_resources. Couldn’t be easier
Eric.

Craig W. 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.

#10

On Sat, 2006-02-11 at 17:33 +1100, Eric S. 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.

:wink:

Happy birthday dude

Craig


#11

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 W. removed_email_address@domain.invalid 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.


#12

LOL - I tell my kids that too


#13

On Fri, 2006-04-07 at 16:02 +0200, Luigi R. 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


#14

On Fri, 2006-04-07 at 18:04 +0200, Maurizio B. wrote:

class=“demo_link”><%= @task.due_date.strftime("%d/%m/%y") %>
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. :slight_smile:


No, I think I understand…


<%= @task.due_date %>

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


#15

On 4/7/06, Craig W. removed_email_address@domain.invalid 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.


<%= @task.due_date.strftime("%d/%m/%y") %>

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. :slight_smile: