Fix .class to .class.to_s

This commit is contained in:
Christophe Vilayphiou 2012-07-30 18:34:54 +08:00
parent f3ccbce5c8
commit 39b63a970c
10 changed files with 18 additions and 18 deletions

View File

@ -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'

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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 << "<div class='with_action'><i class='icons-moves'></i>"
ret << (link_to node.title, dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>"
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 << "</div>"
ret << "</div>"
ret << render_children(node)

View File

@ -515,7 +515,7 @@
<% @recent_updated.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class..to_sunderscore) %></td>
</tr>
<% end %>
</tbody>
@ -553,7 +553,7 @@
<% @most_visited.each do |object| %>
<tr>
<td><%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0].class.underscore}"), get_link(object[0].class.underscore) %></td>
<td class="span2"><%= link_to t("dashboard.#{object[0].class.to_s.underscore}"), get_link(object[0].class.to_s.underscore) %></td>
<td class="span2"><%= object[1] %></td>
</tr>
<% end %>

View File

@ -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" %>

View File

@ -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' %>

View File

@ -17,7 +17,7 @@ module ParserBackEnd
# item = Item.first(:conditions => { :path => tag.attr['name'] })
# ret = ''
# ret << "<a href='"
# ret << eval("admin_#{item.class.downcase}_path(item.id)")
# ret << eval("admin_#{item.class.to_s.downcase}_path(item.id)")
# ret << "' class='nav'>"
# ret << item.i18n_variable[I18n.locale]
# ret << "</a>"

View File

@ -28,7 +28,7 @@ module ParserCommon
res << " active" if (current_page.id.eql?(page.id) || current_page.descendant_of?(page))
res << "'>"
root = "/"
res << "<a href='#{edit ? root + admin_page_path(page.id) : (page.class.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>"
res << "<a href='#{edit ? root + admin_page_path(page.id) : (page.class.to_s.eql?('Page') ? root + page.path : page.url)}'><span>#{page.title}</span></a>"
if page.visible_children.size > 0 && current < menu.levels
res << "<span class='dot'></span>"
res << menu_level(page, current_page, current + 1, menu, edit)
@ -121,7 +121,7 @@ module ParserCommon
menu_page.visible_children.each do |child|
res << "<li class='#{page.id.eql?(child.id) ? 'active' : nil}'>"
root = "/"
res << "<a href='#{edit ? root + admin_page_path(child.id) : (child.class.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>"
res << "<a href='#{edit ? root + admin_page_path(child.id) : (child.class.to_s.eql?('Page') ? root + child.path : child.url)}'>#{child.title}</a>"
res << "</li>"
end
res << "</ul>"