Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

ActionController::RoutingError (No route matches [GET] "/system/pictures/assets/small/IMG_-_WIN_20141206_09

I'm trying to upload pictures in my rails app, bt it's giving me error:- ActionController::RoutingError (No route matches [GET] "/system/pictures/assets/small/IMG_-_WIN_20141206_09. I don't know where i went wrong.

I try to give :url and :path also and i also upload image of rails logo and move to app/assets/images

$curl -O http://rubyonrails.org/image/rails.png

$ mv rails.png app/assets/images/

My git repository is at: https://github.com/sarahgupta022/book.git

This is my picture.rb

class Picture < ActiveRecord::Base

belongs_to :album

belongs_to :user

attr_accessible :caption, :description, :asset

has_attached_file :asset, style: { 
                      large: "800x800>", medium: "300x200>", small: "260x180>", thumb: "80x80#"
                      } , :default_url => "/app/assets/images/small/rails.png"


  validates_attachment_file_name :asset, :matches => [/png\Z/, /jpe?g\Z/, /gif\Z/]
 validates :asset, attachment_presence: true



  def to_s
    caption? ? caption : "Picture"
  end                    

end

This is my views/pictures/index.html.erb

<p id="notice"><%= notice %></p> <%= page_header do %> <% if signed_in? && current_user == @user %> <%= link_to 'Add Picture', new_album_picture_path(current_user, @album), class: 'btn pull-right' %> <% end %> <h1><%= @album.title %></h1> <% end %>

<ul class="thumbnails"> <% @pictures.each do |picture| %> <li> <div class="thumbnail"> <%= link_to image_tag(picture.asset.url(:small)), album_picture_path(@user, @album, picture) %><br /><br /> <div class="caption"> <% if picture.caption? %><%= picture.caption %><br /><br /><% end %>

            <%= link_to 'View full size', album_picture_path(@user, @album, picture) %>

            <% if can_edit_picture?(picture) %>
            <%= link_to "Edit", edit_album_picture_path(@album, picture) %>
            <%= link_to "Delete", album_picture_path(@album, picture), method: :delete, data: { confirm: "Are you sure?" } %>
            <% end %>
            </div>
            </div>
        </li>
<% end %>

</ul>

Greatly appreciate any help. Thank you!

1 Answer

This is the Issue.

:default_url => "/app/assets/images/small/rails.png"

You may not need the "/app/assets/images" just the "/small/rails.png" Here is an example of an image tag code I use.

<%= image_tag("image.png", size: "75x75", class: "img-responsive logo") %>

I know that is in the html but you can see that the assets pipeline doesn't need or want the rest of the url. This may or may not help you.

After reading assets pipeline, i make changes in my config/environments/development.rb and config/application

config/environments/development.rb

config.assets.digest = false

config.assets.debug = false

In config/application.rb

config.assets.enabled = false

and i also run
RAILS_ENV=production bin/rake assets:precompile

I also remove

:default_url => "/app/assets/images/small/rails.png"

bt still problem is same