这可能是 Ruby 专业人士的一个答案。我收到语法错误:
unexpected tLBRACE at line 1
我相信这与此处描述的问题密切相关,但我无法弄清楚我的情况有什么问题。
有人可以指出什么问题吗?感谢您的时间。
def user_profile_picture(user, size: [50, 50], type: :square, style: 'img-polaroid', opts: {})
tag :img,
{ width: ("#{size[0]}px" if size),
height: ("#{size[1]}px" if size),
src: facebook_profile_picture(user, type),
alt: '',
class: [('verified' if user.class == User.model_name && user.facebook_verified?), style].compact.join(' ')
}.merge(opts)
end
ruby 1.9.3p327(2012-11-10 修订版 37606)[x86_64-darwin11.4.0]
****堆栈跟踪****
SyntaxError - /Developer/rails-workspace/roommate/app/helpers/users_helper.rb:7: syntax error, unexpected tLABEL
...er_profile_picture(user, size: [50, 50], type: :square, sty...
... ^
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:7: syntax error, unexpected ',', expecting keyword_end
..._picture(user, size: [50, 50], type: :square, style: 'img-p...
... ^
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:7: syntax error, unexpected ',', expecting keyword_end
...:square, style: 'img-polaroid', opts: {})
... ^
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:10: syntax error, unexpected ',', expecting keyword_end
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:11: syntax error, unexpected ',', expecting keyword_end
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:12: syntax error, unexpected ',', expecting keyword_end
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:15: syntax error, unexpected '}', expecting keyword_end
}.merge(opts)
^
/Developer/rails-workspace/roommate/app/helpers/users_helper.rb:127: syntax error, unexpected keyword_end, expecting $end:
app/helpers/users_helper.rb:7:in `'
(gem) activesupport-3.2.9/lib/active_support/dependencies.rb:469:in `block in load_file'
(gem) activesupport-3.2.9/lib/active_support/dependencies.rb:639:in `new_constants_in'
(gem) activesupport-3.2.9/lib/active_support/dependencies.rb:468:in `load_file'