我安装宝石‘曲别针’和railscasts.Image用它作为显示出现在页面上‘秀’,但在网页‘指数’告诉我错误:未定义的方法`形象”为#<::条4 ActiveRecord_Relation.Rails
undefined method `image' for #<Article::ActiveRecord_Relation:0x007fbab4814310>
这是我的index.html.erb
<% @article.each do |article| %>
<div class="main-page-blocks">
<%= image_tag @article.image.url(:small) %>
<h3><%= article.title %></h3>
<div class="main-page-articles"><%= article.body %></div>
</div>
<% end %>
这是我的模型article.rb
class Article < ActiveRecord::Base
has_attached_file :image, :styles => { :small => "150x150"}
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
end
在哪里错误?
你有没有做过具体的回形针迁移? la'rails生成回形针文章图像'。 – 2014-10-02 17:54:01
是的,这里有http://pastie.org/9614395 – 138weare 2014-10-02 17:56:55