dhtmlcalendar in ActiveScaffold

To control the date format in dhtmlcalendar within ActiveScaffold in Ruby on Rails, to make the date of 2 November 2007 appear like 02-11-2007, use:

i) if you want to affect the settings in all the application add the following to the top of your controllers/application.rb

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = ‘%d-%m-%Y’

ii) If you only want to affect the settings of the calendar in one specific controller, then add the same line only to the controller that you want:

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = '%d-%m-%Y'

File column plugin with ActiveScaffold upload branch

When using the file_column plugin in the active_scaffold upload branch, the documentation in the file_column doesn’t make it clear what we have to change to make it work.

In the example below the model is number and the file_column is intro.

1. In models/number.rb add:

file_column :intro

2. in controllers/numbers_controller.rb, make sure we have:

config.create.multipart = true
config.update.multipart = true

3. in helpers/numbers_helper.rb add:

def intro_form_column(record, input name)
  file_column_field 'record', :intro
end

def intro_column(record)
  record.intro ? link_to(File.basename(record.intro),
    url_for_file_column(record,'intro'), :popup => true) : "-"
end

4. in views/numbers/_intro_form_column.rhtml add:


  <%= file_column_field  'record', 'intro' %>