diff --git a/app/controllers/admin/sheets_controller.rb b/app/controllers/admin/sheets_controller.rb index 608ae9b..2d0e4c9 100644 --- a/app/controllers/admin/sheets_controller.rb +++ b/app/controllers/admin/sheets_controller.rb @@ -49,7 +49,7 @@ class Admin::SheetsController < ApplicationController if params[:sheet_filter] @sheets = Sheet.search_by_params(params[:sheet_filter]) else - @sheets = Sheet.all(:limit => 100) + @sheets = Sheet.limit(100).all end end diff --git a/app/helpers/link_to_function_helper.rb b/app/helpers/link_to_function_helper.rb new file mode 100644 index 0000000..e584a56 --- /dev/null +++ b/app/helpers/link_to_function_helper.rb @@ -0,0 +1,11 @@ +module LinkToFunctionHelper + def link_to_function(name, *args, &block) + html_options = args.extract_options!.symbolize_keys + + function = block_given? ? update_page(&block) : args[0] || '' + onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;" + href = html_options[:href] || '#' + + content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick)) + end +end \ No newline at end of file diff --git a/app/views/admin/sheets/_sheets_search.html.haml b/app/views/admin/sheets/_sheets_search.html.haml index f1183cc..1ff370d 100644 --- a/app/views/admin/sheets/_sheets_search.html.haml +++ b/app/views/admin/sheets/_sheets_search.html.haml @@ -5,8 +5,8 @@ %td %h4 Dernier renouvellement : - -last_year= SheetYear.find(:first, :order => "year DESC").year - -first_year= SheetYear.find(:first, :order => "year ASC").year + -last_year= SheetYear.order("year DESC").first.year + -first_year= SheetYear.order("year ASC").first.year -y = last_year #sheet_years_search_years %p @@ -28,7 +28,7 @@ %a{:href => "#", :onclick => "$('#cities input:checkbox').attr('checked', false);return false"} Tout désélectionner - -Sheet.find(:all, :group => :city, :order => :city).each do |c| + -Sheet.group(:city).order(:city).all.each do |c| =check_box_tag "sheet_filter[sheet_city][]", c.city, (true if params[:sheet_filter] and params[:sheet_filter][:sheet_city] and params[:sheet_filter][:sheet_city].include?(c.city)) =c.city %br diff --git a/app/views/admin/sheets/index.html.haml b/app/views/admin/sheets/index.html.haml index 280390a..8cc8d9f 100644 --- a/app/views/admin/sheets/index.html.haml +++ b/app/views/admin/sheets/index.html.haml @@ -1,5 +1,5 @@ --last_year= SheetYear.find(:first, :order => "year DESC").year --first_year= SheetYear.find(:first, :order => "year ASC").year +-last_year= SheetYear.order("year DESC").first.year +-first_year= SheetYear.order("year ASC").first.year -y = last_year #stat_years