Rails 显示图像 URL 而不是图像
Rails shows the image URL rather then the image
我有一个 gridview,其中的网格 class (app/grids/users_grid.rb) 包括下面的列。但是,该页面不显示图像,而是显示图像的URL。
column(:name, :html => true, :mandatory => true) do |user|
user.name + image_path("image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end
加载页面时显示的名称不是带有图像的名称:“/assets/image-d723a44cbcf692df07dbeb65d9ae3d1280f34457d939dafba828a41461623d6c.gif”。我该如何纠正这个问题?它可能与在 rb 文件中使用 +
有关吗?
我猜你应该用 image_tag
替换 image_path
尝试:
column(:name, :html => true, :mandatory => true) do |user|
content_tag :div do
content_tag(:span, user.name) +
image_tag("image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end
end
试试这个
column(:name, :html => true, :mandatory => true) do |user|
user.name + image_tag("/assets/image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end
我有一个 gridview,其中的网格 class (app/grids/users_grid.rb) 包括下面的列。但是,该页面不显示图像,而是显示图像的URL。
column(:name, :html => true, :mandatory => true) do |user|
user.name + image_path("image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end
加载页面时显示的名称不是带有图像的名称:“/assets/image-d723a44cbcf692df07dbeb65d9ae3d1280f34457d939dafba828a41461623d6c.gif”。我该如何纠正这个问题?它可能与在 rb 文件中使用 +
有关吗?
我猜你应该用 image_tag
image_path
尝试:
column(:name, :html => true, :mandatory => true) do |user|
content_tag :div do
content_tag(:span, user.name) +
image_tag("image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end
end
试试这个
column(:name, :html => true, :mandatory => true) do |user|
user.name + image_tag("/assets/image.gif", title: "image", style: "max-height: 30px; max-width: 20px")
end