From 39b63a970ce2e264a3754e9fed7d0c837b8c483f Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 30 Jul 2012 18:34:54 +0800 Subject: [PATCH] Fix .class to .class.to_s --- app/controllers/admin/purchases_controller.rb | 4 ++-- app/controllers/pages_controller.rb | 2 +- app/controllers/sessions_controller.rb | 4 ++-- app/helpers/admin/dashboard_helper.rb | 2 +- app/helpers/admin/item_helper.rb | 10 +++++----- app/views/admin/dashboards/index.html.erb | 4 ++-- app/views/admin/items/index.html.erb | 2 +- app/views/admin/items/index.js.erb | 2 +- lib/parsers/parser_back_end.rb | 2 +- lib/parsers/parser_common.rb | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index 7caaf730..ab5b047d 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -32,7 +32,7 @@ class Admin::PurchasesController < ApplicationController public_key = OpenSSL::PKey::RSA.new(File.read(APP_CONFIG['main_public_key'])) encrypted_data = public_key.public_encrypt({:purchase_id => purchase.purchase_id, - :purchase_type => purchase.class, + :purchase_type => purchase.class.to_s, :roaming_id => Site.find(session[:site]).roaming_id, :url => url}.to_json) @@ -43,7 +43,7 @@ class Admin::PurchasesController < ApplicationController temp_file.write response.body temp_file.rewind zip_name = response['content-disposition'].split('filename=')[1].gsub(/[\\\"]|.zip/, '') rescue '' - case purchase.class + case purchase.class.to_s when 'Pdesign' unzip_design(temp_file, zip_name) when 'PModuleApp' diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e0193715..3b0978f9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -22,7 +22,7 @@ class PagesController < ApplicationController @item = Item.first(:conditions => {:path => params[:page_name]}) if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) # impressionist(@item) - case @item.class + case @item.class.to_s when 'Page' render_page when 'Link' diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 621f93d3..39904a1c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -30,7 +30,7 @@ class SessionsController < Devise::SessionsController render :action => "new" else logger.info "===ALL passed" - resource_name = resource.class.downcase + resource_name = resource.class.to_s.downcase sign_in(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource) end @@ -48,7 +48,7 @@ class SessionsController < Devise::SessionsController logger.info "=======Rulingcom account======" resource = User.first(conditions:{email: login_uid}) if resource.valid_password?(login_password) - resource_name = resource.class.downcase + resource_name = resource.class.to_s.downcase sign_in(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource) else diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb index afeaa278..bbfde448 100644 --- a/app/helpers/admin/dashboard_helper.rb +++ b/app/helpers/admin/dashboard_helper.rb @@ -14,7 +14,7 @@ module Admin::DashboardHelper end def get_link_to_object(object) - case object.class.underscore + case object.class.to_s.underscore when 'bulletin' panel_announcement_front_end_bulletin_path(object) when 'news_bulletin' diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index 4aec798e..f5b8589a 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -3,7 +3,7 @@ module Admin::ItemHelper def render_node_and_children(node) ret = '' if node - case node.class + case node.class.to_s when 'Page' dest = admin_page_path(node) when 'Link' @@ -15,10 +15,10 @@ module Admin::ItemHelper ret << "
" ret << (link_to node.title, dest, :class => 'js_history') ret << "
" - ret << (link_to t('admin.edit'), eval("edit_admin_#{node.lass.downcase}_path(node)"), :class => 'js_history') if node.lass.eql?('Page') - ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.lass.eql?('Page') - ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.lass.eql?('Page') - ret << (link_to t(:delete), eval("delete_admin_#{node.lass.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') + ret << (link_to t('admin.edit'), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node.class.to_s.eql?('Page') + ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node.class.to_s.eql?('Page') + ret << (link_to t(:delete), eval("delete_admin_#{node.class.to_s.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history') ret << "
" ret << "
" ret << render_children(node) diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index fd821420..8f21d171 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -515,7 +515,7 @@ <% @recent_updated.each do |object| %> <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> - <%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %> + <%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class..to_sunderscore) %> <% end %> @@ -553,7 +553,7 @@ <% @most_visited.each do |object| %> <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> - <%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %> + <%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %> <%= object[1] %> <% end %> diff --git a/app/views/admin/items/index.html.erb b/app/views/admin/items/index.html.erb index f3d6c1c4..92af4611 100644 --- a/app/views/admin/items/index.html.erb +++ b/app/views/admin/items/index.html.erb @@ -2,4 +2,4 @@ <%= render 'admin/items/site_map_left_bar' %> <% end -%> -<%= render "admin/#{@item.class.downcase.pluralize}/show" %> +<%= render "admin/#{@item.class.to_s.downcase.pluralize}/show" %> diff --git a/app/views/admin/items/index.js.erb b/app/views/admin/items/index.js.erb index fb2d5702..bc701ca2 100644 --- a/app/views/admin/items/index.js.erb +++ b/app/views/admin/items/index.js.erb @@ -1,5 +1,5 @@ $('#back_main').empty(); -<% case @item.class %> +<% case @item.class.to_s %> <% when 'Page' %> $('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>"); <% when 'Link' %> diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index bce4c064..2a590417 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -17,7 +17,7 @@ module ParserBackEnd # item = Item.first(:conditions => { :path => tag.attr['name'] }) # ret = '' # ret << "" # ret << item.i18n_variable[I18n.locale] # ret << "" diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 39a9733f..f3d1268e 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -28,7 +28,7 @@ module ParserCommon res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page)) res << "'>" root = "/" - res << "#{page.title}" + res << "#{page.title}" if page.visible_children.size > 0 && current < menu.levels res << "" res << menu_level(page, current_page, current + 1, menu, edit) @@ -121,7 +121,7 @@ module ParserCommon menu_page.visible_children.each do |child| res << "
  • " root = "/" - res << "#{child.title}" + res << "#{child.title}" res << "
  • " end res << ""