我刚刚尝试过,rails_admin
在保存包含变音符号的字符串时遇到了问题(例如“ü,ö,ä ...”)。模型已保存到数据库,但后续屏幕失败。
incompatible character encodings: UTF-8 and ASCII-8BIT
Extracted source (around line #17):
14: = menu_for((@abstract_model ? (@object.try(:persisted?) ? :member : :collection) : :root), @abstract_model, @object)
15: = content_for :contextual_tabs
16: = yield
17:
18: %footer
19: %p © RailsAdmin 2012
我还尝试使用 before_save 钩子对 utf8 中的字符串进行编码,但是在按下保存后,错误仍然存在:
我的模特
# encoding: utf-8
require 'carrierwave/orm/activerecord'
class Product < ActiveRecord::Base
mount_uploader :img_small, ProductImgSmallUploader
mount_uploader :img_large, ProductImgLargeUploader
attr_accessible :img_small, :img_small_cache, :remove_img_small
attr_accessible :img_large, :img_large_cache, :remove_img_large
attr_accessible :title_de, :title_en, :description_de, :description_en, :visible
before_save do
[:title_de,:title_en,:description_de,:description_en].each do |arg|
if self.try arg
self.send("#{arg}=", self.send(arg).encode('UTF-8'))
end
end
end
end
关于如何在我这边解决它的任何建议?还是我必须分叉宝石?
完整的堆栈跟踪
rails_admin (0.1.2) app/views/layouts/rails_admin/pjax.html.haml:17:in `_c___uby____lib_ruby_gems_______gems_rails_admin_______app_views_layouts_rails_admin_pjax_html_haml___1061959050_34768032'
actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.8) lib/action_view/template.rb:143:in `render'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.8) lib/action_view/helpers/rendering_helper.rb:24:in `render'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:11:in `block in render_with_haml'
haml (3.1.7) lib/haml/helpers.rb:90:in `non_haml'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:11:in `render_with_haml'
rails_admin (0.1.2) app/views/layouts/rails_admin/application.html.haml:27:in `_c___uby____lib_ruby_gems_______gems_rails_admin_______app_views_layouts_rails_admin_application_html_haml___191072136_5393304'
actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.8) lib/action_view/template.rb:143:in `render'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
c:/Ruby193/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render'
remotipart (1.0.2) lib/remotipart/render_overrides.rb:8:in `render'
rails_admin (0.1.2) lib/rails_admin/config/actions/index.rb:35:in `block (4 levels) in '
actionpack (3.2.8) lib/action_controller/metal/mime_responds.rb:196:in `call'
actionpack (3.2.8) lib/action_controller/metal/mime_responds.rb:196:in `respond_to'
rails_admin (0.1.2) lib/rails_admin/config/actions/index.rb:32:in `block (2 levels) in '
(eval):8:in `instance_eval'
(eval):8:in `index'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:469:in `_run__375825897__process_action__876887233__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
rack-pjax (0.6.0) lib/rack/pjax.rb:12:in `call'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (1.1.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
remotipart (1.0.2) lib/remotipart/middleware.rb:30:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__979894838__call__1042350755__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
c:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
c:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
c:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
使用的宝石
$ bundle show
Gems included by the bundle:
* actionmailer (3.2.8)
* actionpack (3.2.8)
* activemodel (3.2.8)
* activerecord (3.2.8)
* activeresource (3.2.8)
* activesupport (3.2.8)
* arel (3.0.2)
* bcrypt-ruby (3.0.1)
* bootstrap-sass (2.1.0.1)
* builder (3.0.2)
* bundler (1.1.4)
* carrierwave (0.7.0)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* devise (2.0.4)
* erubis (2.7.0)
* execjs (1.4.0)
* font-awesome-sass-rails (2.0.0.0)
* haml (3.1.7)
* hike (1.2.1)
* i18n (0.6.1)
* journey (1.0.4)
* jquery-rails (2.1.2)
* jquery-ui-rails (2.0.2)
* json (1.7.5)
* kaminari (0.14.1)
* mail (2.4.4)
* mime-types (1.19)
* multi_json (1.3.6)
* mysql (2.8.1)
* nested_form (0.2.3)
* nokogiri (1.5.5)
* orm_adapter (0.0.7)
* polyglot (0.3.3)
* rack (1.4.1)
* rack-cache (1.2)
* rack-pjax (0.6.0)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.8)
* rails_admin (0.1.2)
* railties (3.2.8)
* rake (0.9.2.2)
* rdoc (3.12)
* remotipart (1.0.2)
* sass (3.2.1)
* sass-rails (3.2.5)
* sprockets (2.1.3)
* sqlite3 (1.3.6)
* thor (0.16.0)
* tilt (1.3.3)
* treetop (1.4.10)
* twitter-bootstrap-rails (2.0.7 ad1b849)
* tzinfo (0.3.33)
* uglifier (1.3.0)
* warden (1.1.1)