From e0a7e0fec760ba12c8067a37e10c96f1f05876e2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 04:13:16 +0200 Subject: Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade - Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs --- app/helpers/application_helper.rb | 11 +++++++++++ app/helpers/content_helper.rb | 10 ++++------ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22a7940e..0be66e90 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,14 @@ # Methods added to this helper will be available to all templates in the application. module ApplicationHelper + def form_error_messages(form_object) + object = form_object.is_a?(ActionView::Helpers::FormBuilder) ? form_object.object : form_object + return "" unless object && object.errors.any? + content_tag(:div, :class => "error_messages") do + content_tag(:ul) do + object.errors.full_messages.map do |msg| + content_tag(:li, msg) + end.join.html_safe + end + end + end end diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 17364f8b..dbe468e3 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -1,7 +1,7 @@ module ContentHelper def main_menu - menu_items = MenuItem.all(:order => "position ASC") + menu_items = MenuItem.order("position ASC").all render( :partial => 'content/main_navigation', :locals => {:menu_items => menu_items} @@ -51,7 +51,7 @@ module ContentHelper end def page_title - if @page.title && @page.title != "" + if @page && @page.title && @page.title != "" "CCC | #{@page.title}" else "CCC | Chaos Computer Club" @@ -75,7 +75,7 @@ module ContentHelper def aggregate? content options = {} - cccms_attributes = ActionView::Base.sanitized_allowed_attributes + [ 'lang' ] + cccms_attributes = ActionView::Base.sanitized_allowed_attributes + ['lang'] begin if content =~ /]*)>/ @@ -126,9 +126,7 @@ module ContentHelper # Check if a custom partial exists in the proper location def partial_exists? partial File.exist?( - File.join( - RAILS_ROOT, 'app', 'views', 'custom', 'partials', "_#{partial}.html.erb" - ) + Rails.root.join('app', 'views', 'custom', 'partials', "_#{partial}.html.erb") ) end -- cgit v1.3