jquery 当在ruby on rails应用程序中点击localhost时,得到“Psych::SyntaxError in HomeController#index”

nwnhqdif  于 2023-05-17  发布在  jQuery
关注(0)|答案(1)|浏览(146)

所以,这个项目是在2010年初用ruby 1.8.7,rails 2.3.18和mysql数据库构建的。升级到ruby 1.9.3和mysql 8后,项目抛出标题中提到的错误。与Psych::Syntax error一起,它说,

(<unknown>): did not find expected node content while parsing a flow node at line 13 column 14

现在有趣的是,如果我注解掉config/locales/sv.yml中用于翻译的第13行,项目就能成功运行。我目前在黑暗中如何或为什么它是工作。这里是*sv.yml*的前23行。
下面是
../app/controllers/home_controller.rb
文件中的index函数,根据应用程序跟踪,错误从该文件开始。

def index
    render "index#{params[:v]}"
end

下面是应用程序跟踪的内容:

/home/../.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/psych.rb:203:in `parse'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/psych.rb:151:in `parse'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/psych.rb:127:in `load'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb:227:in `load_yml'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb:214:in `load_file'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb:21:in `block in load_translations'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb:21:in `each'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb:21:in `load_translations'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb:57:in `init_translations'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb:40:in `available_locales'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n/config.rb:38:in `available_locales'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/vendor/i18n-0.4.1/i18n.rb:35:in `available_locales'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/template.rb:226:in `valid_locale?'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/template.rb:243:in `parse_extensions'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/template.rb:233:in `split'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/template.rb:118:in `initialize'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:81:in `initialize'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:38:in `new'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:38:in `register_template_from_file'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:62:in `block in load_all_templates_from_dir'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:62:in `each'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:62:in `load_all_templates_from_dir'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/reloadable_template.rb:29:in `[]'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/paths.rb:48:in `block in find_template'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/paths.rb:47:in `each'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_view/paths.rb:47:in `find_template'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:1391:in `default_template'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/layout.rb:265:in `candidate_for_layout?'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/layout.rb:245:in `pick_layout'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:915:in `render'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:51:in `block in render_with_benchmark'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/activesupport-2.3.18/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/home/../.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:51:in `render_with_benchmark'
/home/../project/app/controllers/home_controller.rb:17:in `index'

另一个我没能重现的有趣的事情是,如果我在服务器运行时注解掉第13行,有时它会指向视图文件的第98行,引用相同的错误。代码如下:../app/view/event/partials/_event_details_form.html.haml

95   %p.field#start_time
96          = f.label :start_time, "%s: " % ["Start time"[:event_start_time]]
97          - # TODO: Switch to jQuery-UI Datepicker f.text_field :start_time, :value => f.object.start_time.to_s.split(" ").first
98          = date_picker f, :start_time
99          -# DISABLED: %strong= link_to "Hide"[:event_start_time_hide], 'javascript: return false;', :id => 'hide-start_time'
100         - # %span.hint= "Event starts at?"
101
102       - if f.object.start_time.present?
103         :javascript
104           $j(function() {
105             $j("#start_time").show();
106             $j("#show-start_time").hide();
107           });
108       - else
109         :javascript
110           $j(function() {
111             $j("#start_time").hide();
112             $j("#show-start_time").show();
113           });

我怀疑sv.yml的第13行的order与**_event_details_form.html.haml的第98**行的date_picker有关。此外,日期选择器功能如下,

$j.datepicker.setDefaults($.datepicker.regional['sv']);
   $j("#event_start_time").datepicker({
     dateFormat: "yy-mm-dd",
     autoSize: true,
     buttonImage: '/images/datepicker.gif'
   });
vwkv1x7d

vwkv1x7d1#

你不能在“order”数组中使用冒号。如果你真的需要冒号,你必须用引号将数组的每一项括起来。

13     order: [':year', ':month', ':date']

相关问题