提问人:Chaitali 提问时间:1/17/2020 最后编辑:Roman AlekseievChaitali 更新时间:1/18/2020 访问量:1819
提供无位置。无法为 Rails 5.2 构建 URI
Nil location provided. Can't build URI for Rails 5.2
问:
我对 Ruby 编程很陌生。将应用程序从 Rails 4 升级到 5.2。运行 RSpec 时出现以下错误。Rails 版本和其他更改已经完成。不确定如何解决错误。
Failure/Error: = image_tag current_user.gravatar_url, class: 'gravatar'
ActionView::Template::Error: Nil location provided. Can't build URI.
# ./app/views/layouts/_navigation.html.haml:25:in `_app_views_layouts__navigation_html_haml___4566101014686141882_47249923845420'
# ./app/views/layouts/application.html.haml:15:in `_app_views_layouts_application_html_haml__778403214308649385_47249873224260'
# ./spec/controllers/clones_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ArgumentError:
# Nil location provided. Can't build URI.
# ./app/views/layouts/_navigation.html.haml:25:in `_app_views_layouts__navigation_html_haml__
Gravatar 定义:user.rb
def gravatar_url
md5 = Digest::MD5.hexdigest(email)
"https://www.gravatar.com/avatar/#{md5}"
end
_navigation.html.haml
文件:
%ul.nav.navbar-nav.pull-right{:style => 'font-size:12px'}
- if user_signed_in?
%li.dropdown.profile
%a.dropdown-toggle{:'data-toggle' => 'dropdown'}
= image_tag current_user.gravatar_url, class: 'gravatar'
= current_user.name
%b.caret
%ul.dropdown-menu
%li= link_to 'Permissions', command_permissions_path if can? :index, CommandPermission
%li= link_to 'Logout', logout_path, :method => :delete
答:
0赞
ARK
1/18/2020
#1
您的操作正在返回,因为在某些时候它从 .您需要观察 返回的字符串(如果在循环中,则在每个周期中)并找出它返回的原因。这就是问题所在。gravatar_url
user.rb
nil
md5
gravatar_url
nil
评论