加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 期望在Rails文件中使用tASSOC

发布时间:2020-12-17 04:37:47 所属栏目:百科 来源:网络整理
导读:我确定我在这里做了一些蠢事,但我看不到它. 我在应用程序视图中调用了breadcrumb方法. app / helpers / breadcrumbs_helper.rb说: module BreadcrumbsHelper def breadcrumb @crumb_list = [] drominay_crumb_builder project_crumb_builder content_tag(:d
我确定我在这里做了一些蠢事,但我看不到它.

我在应用程序视图中调用了breadcrumb方法.

app / helpers / breadcrumbs_helper.rb说:

module BreadcrumbsHelper

  def breadcrumb
    @crumb_list = []
    drominay_crumb_builder
    project_crumb_builder
    content_tag(:div,:id => "breadcrumbs",@crumb_list.map { |list_item| crumb_builder(list_item) })
  end

  def crumb_builder(list_item)
    if list_item == @crumb_list.last
      content_tag(:span,list_item['body'],:class => list_item['crumb'])
    else
      body = ["list_item['body']"," → "].join
      link_to(body,list_item['url'],:class => list_item['crumb'])
    end
  end

  def drominay_crumb_builder
    list_item = Hash.new
    list_item['body'] = "Drominay"
    list_item['url'] = "root"
    @crumb_list << list_item
  end

  def project_crumb_builder
  end

end

为什么我为什么会得到这个“期待tASSOC”错误? (无论如何,什么是tASSOC?)

steven-nobles-imac-200:drominay steven$script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /Users/steven/Drominay/app/helpers/breadcrumbs_helper.rb:7: syntax error,unexpected ')',expecting tASSOC (SyntaxError)
/Users/steven/Drominay/app/helpers/breadcrumbs_helper.rb:29: syntax error,unexpected $end,expecting kEND
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
 from /Users/steven/Drominay/app/helpers/application_helper.rb:5
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:382:in `load_without_new_constant_marking'
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:382:in `load_file'
 from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
  ... 56 levels...
 from /Users/steven/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 from script/server:3

解决方法

tASSOC表示=>操作者

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读