开发者

Rails 3, cannot see my "model"_path

开发者 https://www.devze.com 2023-02-20 00:47 出处:网络
I am working on a rails 3 projects. One of my model is the following one (it uses paperclip to upload an image)

I am working on a rails 3 projects. One of my model is the following one (it uses paperclip to upload an image)

class Picture < ActiveRecord::Base
  has_and_belongs_to_many :categories
  has_attached_file :pict,
                :styles => { :small  => "150x150>" }

  validates_attachment_presence :pict
  validates_attachment_size :pict, :less_than => 5.megabytes
  validates_attachment_content_type :pict, :content_type => ['image/jpeg', 'image/png', 'image/gif']

end

In its index.html.erb, I have added a "link_to" to delete the record, but the following does not work:

undefined method `picture_path' for #<#<Class:0x10549f560>:0x10549d940>

Extracted source (around line #16):

8: <table class="gallery">
9:  <tr>
10:  <% i=0 %>
11:  <% @pictures.each do |picture| %>
12:  <% if i%4 == 0 then %>
13:     </tr><tr>
14:     <% end%>
15:       <td><%= link_to image_tag(picture.pict.url(:small)), picture.pict.url %></td>
16:       <td><%= link_to image_tag("delete.png"), picture, :confirm => 'Are you sure?', :method => :delete %></td>开发者_Go百科
17:     <% i=i+1 %>
18:   <% end %>
19:   </tr>

I already use the very same line (16) for another model and I do not have this error.

could you please help ?

Thanks and Regards,

Luc


It looks like you're missing 'picture' routes in your routes.rb file....

resources :pictures
0

精彩评论

暂无评论...
验证码 换一张
取 消