Ruby on rails Rails:图像标签问题

Ruby on rails Rails:图像标签问题,ruby-on-rails,image,scope,carrierwave,Ruby On Rails,Image,Scope,Carrierwave,我不明白为什么这不起作用。我的索引页中有事件,我想用图片和标题显示其中三个,所以 在我的事件模型中: scope :host_admin, where(hoster_type: "Admin").order("start_time DESC").limit(3) 在索引页中: <% Event.host_admin.each do |event| %> <%= image_tag(event.image(:home)) %> <p class="eve

我不明白为什么这不起作用。我的索引页中有事件,我想用图片和标题显示其中三个,所以

在我的事件模型中:

  scope :host_admin, where(hoster_type: "Admin").order("start_time DESC").limit(3)
在索引页中:

<% Event.host_admin.each do |event| %>
  <%= image_tag(event.image(:home)) %>
  <p class="evento"><%= event.title %>
    <%= link_to "read_all", event_path %>
  </p>
<% end %>
错误是: 参数数目错误(1代表0)

这就是问题所在,因为如果我试图替换

      <%= image_tag(event.image(:home)) %>

用这个

      <%= image_tag event.image %>

它可以工作,但我需要调整图像的大小?
有什么建议吗?

您得到的错误是因为您正在传递:home到image对象,而不是url方法。您需要将图像标记更改为:

<%= image_tag(event.image_url(:home)) %>


他说他正在使用carrierwave,而不是paperclip@Faisal谢谢,刚刚重新标记。非常感谢,非常简单。=)
<%= image_tag(event.image_url(:home)) %>