【发布时间】:2015-04-07 20:11:12
【问题描述】:
好吧,我在用回形针获取背景图像时遇到了一些问题,实际上我得到了这个
在 app/views/layouts/application.html.erb
<head>
...
</head>
<body style="<%= show_user_bg %>">
...
</body>
在 app/helpers/application_helper.rb 中
module ApplicationHelper
def show_user_bg
"background:transparent url(#{@user.background_image}) no-repeat fixed left top;"
end
end
还有这个模块助手
module ApplicationHelper
def show_user_bg
# Show user background
if user_signed_in?
"background:transparent url(#{@user.background_image}) no-repeat fixed left top;"
# Otherwise, show a default background image
else
"background:transparent url('/images/default_bg.png') no-repeat fixed left top;"
end
end
end
但是,当我尝试访问图像时,我不知道从哪里获得它。
简历,我想要这个
<%= image_tag(@user.background.url, :width => "100%") %>
到这里
<div style="background:transparent url(#{@user.background.url}) no-repeat fixed left top;">
任何帮助将不胜感激
【问题讨论】:
标签: twitter-bootstrap ruby-on-rails-4 paperclip cover