开发者

How to use subfolders of images in a rails project

开发者 https://www.devze.com 2023-04-11 19:05 出处:网络
I make a folder in public/images called google-markers but when i go to http://myproject/images/google-markers/mymarker.png

I make a folder in public/images called google-markers but when i go to

 http://myproject/images/google-markers/mymarker.png

I got this error :

 No route matches "/images/google-markers/mymarker.png"

It seems, i can't use a subfolder of images in my project. When i use direct images in my images folder, everything works fine.

Thank you for help!

ps : I use passenger for deployment, it's a development version on rails 3.0.9

EDIT :

My config.ru :

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  开发者_开发技巧__FILE__)
run Hotelandlodge::Application

and my development.rb : Hotelandlodge::Application.configure do # Settings specified here will take precedence over those in config/application.rb

    # In the development environment your application's code is reloaded on
    # every request.  This slows down response time but is perfect for development
    # since you don't have to restart the webserver when you make code changes.
    config.cache_classes = false

    # Log error messages when you accidentally call methods on nil.
    config.whiny_nils = true

    # Show full error reports and disable caching
    config.consider_all_requests_local       = true
    config.action_view.debug_rjs             = true
    config.action_controller.perform_caching = false

    # Don't care if the mailer can't send
    config.action_mailer.raise_delivery_errors = false

    # Print deprecation notices to the Rails logger
    config.active_support.deprecation = :log

    Paperclip.options[:command_path] = "/usr/local/bin/"

    # Only use best-standards-support built into browsers
    config.action_dispatch.best_standards_support = :builtin

  end

My config/application.rb :

  require File.expand_path('../boot', __FILE__)

  require 'rails/all'

  # If you have a Gemfile, require the gems listed there, including any gems
  # you've limited to :test, :development, or :production.
  Bundler.require(:default, Rails.env) if defined?(Bundler)

  module Hotelandlodge
    class Application < Rails::Application
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.

      # Custom directories with classes and modules you want to be autoloadable.
      # config.autoload_paths += %W(#{config.root}/extras)

      # Only load the plugins named here, in the order given (default is alphabetical).
      # :all can be used as a placeholder for all plugins not explicitly named.
      # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

      # Activate observers that should always be running.
      # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

      # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
      # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
      # config.time_zone = 'Central Time (US & Canada)'

      # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
      # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
      # config.i18n.default_locale = :de

      # JavaScript files you want as :defaults (application.js is always included).
      # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

      # Configure the default encoding used in templates for Ruby 1.9.
      config.encoding = "utf-8"

      # Configure sensitive parameters which will be filtered from the log file.
      config.filter_parameters += [:password]
    end
  end

My Gemfile :

    source 'http://rubygems.org'

    gem 'rails', '3.0.9'

    # Bundle edge Rails instead:
    # gem 'rails', :git => 'git://github.com/rails/rails.git'

    gem 'mysql2', '< 0.3'
    gem "paperclip", "~> 2.4"

    gem 'activeadmin'
    gem 'will_paginate'

    # Use unicorn as the web server
    # gem 'unicorn'

    # Deploy with Capistrano
    # gem 'capistrano'

    # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
    # gem 'ruby-debug'
    # gem 'ruby-debug19', :require => 'ruby-debug'

    # Bundle the extra gems:
    # gem 'bj'
    # gem 'nokogiri'
    # gem 'sqlite3-ruby', :require => 'sqlite3'
    # gem 'aws-s3', :require => 'aws/s3'

    # Bundle gems for the local environment. Make sure to
    # put test-only gems in this group so their generators
    # and rake tasks are available in development mode:
    # group :development, :test do
    #   gem 'webrat'
    # end


Did you add the path to routes.rb?

0

精彩评论

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

关注公众号