2012-02-05 13 views
7

मैं अपने आवेदन को रेल 3.1.3 से रेल 3.2.1 में अपग्रेड करने का प्रयास करता हूं और मुझे संपत्तियों में समस्या है।रेल 3.1.3 से रेल 3.2.1 तक अपग्रेड करें। संपत्तियों के साथ त्रुटि

मैं त्रुटि के इस प्रकार है:

ActionController::RoutingError (No route matches [GET] "/assets/logos/opera_logo.png"): 
    actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
    railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app' 
    railties (3.2.1) lib/rails/rack/logger.rb:16:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call' 
    rack (1.4.1) lib/rack/methodoverride.rb:21:in `call' 
    rack (1.4.1) lib/rack/runtime.rb:17:in `call' 
    activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
    rack (1.4.1) lib/rack/lock.rb:15:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call' 
    railties (3.2.1) lib/rails/engine.rb:479:in `call' 
    railties (3.2.1) lib/rails/application.rb:220:in `call' 
    rack (1.4.1) lib/rack/content_length.rb:14:in `call' 
    railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call' 
    rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service' 
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' 
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' 
    /usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' 

रेल मेरी सभी परिसंपत्तियों भी नहीं मिलता है लेकिन मुझे लगता है (उदाहरण के लिए/ऐप्स/संपत्ति/images/लोगो) की तुलना में वे सही फ़ोल्डर में हैं।

मैंने अपने सिस्टम को अपग्रेड करने के लिए इस मार्गदर्शिका का पालन किया: http://railscasts.com/episodes/318-upgrading-to-rails-3-2?view=asciicast। यह रेल 3.1 के साथ बहुत अच्छी तरह से चल रहा था। मुझे करने के लिए कोई अन्य बदलाव नहीं मिला है। मैं क्या कर सकता हूँ?

source 'http://rubygems.org' 

gem 'rails', '3.2.1' 

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

gem 'sqlite3' 


# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

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

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
gem 'ruby-debug19', :require => 'ruby-debug' 

group :test do 
    gem 'capybara', '1.1.2' 
    gem 'rspec-rails', '2.8.1' 
    gem 'autotest-rails', '4.1.1' 
    gem 'spork', '0.8.5' 
    gem 'factory_girl_rails', '1.4.0' 
    gem 'email_spec', '1.2.1' 
    gem 'cucumber-rails', '1.2.1' 
    gem 'launchy', '2.0.5' 
    gem 'pickle', '0.4.10' 
    gem 'database_cleaner', '0.7.0' 
    gem 'simplecov', '0.5.4' 
    gem 'simplecov-rcov', '0.2.3' 
    gem "mocha", '0.10.0' 
    gem 'capybara-firebug', '0.0.10' 
    gem "prawn", '0.8.4' 
end 

group :development do 
    gem "nifty-generators", '0.4.6' 
end 

gem 'active_reload', '0.6.1' 
gem "galetahub-simple_captcha", '0.1.3', :require => "simple_captcha" 
gem 'authlogic', '3.1.0' 
gem 'meta_search', '1.1.3' 
gem 'naive_bayes', :git => 'git://github.com/reddavis/Naive-Bayes.git' 

यह मेरा development.rb है:

यह मेरा Gemfile है

Onopia::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 web server 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_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 

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

    # Do not compress assets 
    config.assets.compress = false 

    # Expands the lines which load the assets 
    config.assets.debug = true 

    # Raise exception on mass assignment protection for Active Record models 
    config.active_record.mass_assignment_sanitizer = :strict 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    config.active_record.auto_explain_threshold_in_seconds = 0.5 
end 

और ये मेरे application.rb है:

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

# Pick the frameworks you want: 
require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "active_resource/railtie" 
require "sprockets/railtie" 
# require "rails/test_unit/railtie" 

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    # Bundler.require(:default, :assets, Rails.env) 
end 

module Onopia 
    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 = :fr 

    # 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] 

    # Enable the asset pipeline 
    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 

    # Configure generators values. Many other options are available, 
    # be sure to check the documentation. 
    #config.generators do |g| 
    # g.test_framework :rspec, :fixture => false 
    #end 

    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
    end 
end 

संपादित करें: एक बेहतर उदाहरण ।

मैं इस फ़ाइल को देखना चाहते:

एप्लिकेशन/आस्तियों/javascripts/

application.js जब मैं इस यूआरएल पर जाएँ:

http://localhost:3000/assets/application.js

और मुझे यह त्रुटि है:

Started GET "/assets/application.js" for 127.0.0.1 at 2012-02-06 17:04:38 -0500 
Served asset /application.js - 404 Not Found (1ms) 

ActionController::RoutingError (No route matches [GET] "/assets/application.js"): 
    actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
    railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app' 
    railties (3.2.1) lib/rails/rack/logger.rb:16:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call' 
    rack (1.4.1) lib/rack/methodoverride.rb:21:in `call' 
    rack (1.4.1) lib/rack/runtime.rb:17:in `call' 
    activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
    rack (1.4.1) lib/rack/lock.rb:15:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call' 
    railties (3.2.1) lib/rails/engine.rb:479:in `call' 
    railties (3.2.1) lib/rails/application.rb:220:in `call' 
    rack (1.4.1) lib/rack/content_length.rb:14:in `call' 
    railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call' 
    rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service' 
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' 
    /usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' 
    /usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' 

बहुत बहुत धन्यवाद और आपका दिन शुभ हो।

+0

आप कहते हैं कि संपत्ति 'ऐप/संपत्ति/छवियों 'में है, लेकिन आप छवि को' ऐप/संपत्ति/लोगो ' –

+0

से कॉल कर रहे हैं क्षमा करें, यह मेरी गलती है। मेरी फ़ाइल यहां है: ऐप/संपत्ति/छवियां/लोगो/opera_logo.png। मैंने अपनी पोस्ट संपादित की। – Dougui

+0

मुझे आश्चर्य है कि एक पोस्ट को संपादित करने से रूटिंग एरर संदेश बदल गया है। आपके द्वारा संदर्भित छवि के ऊपर आपके द्वारा संदर्भित 'संपत्ति/छवियों' फ़ोल्डर में नहीं है, बल्कि 'संपत्ति/लोगो 'में है। अपनी फ़ाइल का स्थान 'संपत्ति/लोगो' में बदलें या संदर्भित लिंक को बेहतर तरीके से ढूंढें और इसे 'संपत्ति/छवियों/opera_logo.png' –

उत्तर

2

स्पष्ट रूप से कुछ मणि निर्भरता टूट गई है और bundle exec rails server को हल करना चाहिए ई यह इसे sudo ... के बिना चलाया जाना चाहिए जबतक कि आप आमतौर पर रूट एप के साथ अपने ऐप के साथ काम नहीं करते (जो कि अच्छा नहीं है)। अपनी रेल रूट में फ़ाइलों/फ़ोल्डर अनुमतियों की जांच करें, जो पहले sudo कमांड का दुरुपयोग करके टूटा हुआ हो सकता है। विकास में रहते हुए आपको शायद ही कभी किसी भी रूट विशेषाधिकार की आवश्यकता होती है।

उसके अलावा, similar issues भी समक्ष पेश कर दिया है और इस सवाल का जवाब अपने पूरे gemset, मुख्य रूप से sprockets और रेल अद्यतन करने के लिए किया गया था। आपकी कॉन्फ़िगरेशन फ़ाइलें मेरे लिए ठीक लगती हैं और मैं त्रुटि को पुन: उत्पन्न नहीं कर सकता।

यदि इससे मदद नहीं मिलती है, तो मैं एक नया रेल ऐप तैयार करूंगा, वहां मौजूद एक ही रत्न के साथ काम कर रहे संपत्ति पाइपलाइन की जांच करें और मैन्युअल रूप से सभी कॉन्फ़िगरेशन फ़ाइलों को क्रॉस-चेक करें।

रूटिंग के लिए कई डिबगिंग टूल भी हैं, लेकिन पहले उपरोक्त प्रयास करें।

+0

मैंने आरवीएम के साथ एक नया रत्न स्थापित किया, और यह काम करता है! बहुत बहुत धन्यवाद। – Dougui

+0

मैंने 'बंडल निष्पादन रेल' के साथ रेल सर्वर शुरू किया और यह काम करता है। इस त्रुटि के बारे में स्ट्रज चीज यह है कि अन्य संपत्तियां (जावास्क्रिप्ट, स्टाइलशीट) 'रेल एस' के साथ ठीक काम करती हैं लेकिन छवियां नहीं होती हैं। –

+0

@Giovanni आप समझने के लिए बहुत कम विवरण दे रहे हैं। कृपया, अपनी स्थिति समझाते हुए एक नया प्रश्न शुरू करें। अपने 'Gemfile' को शामिल करना सुनिश्चित करें और उन छवियों को कॉल करें जो काम नहीं करते हैं और पूर्ण त्रुटि संदेश नहीं हैं। –

0

मुझे कुछ इसी तरह का सामना करना पड़ा। आप उनका संदर्भ कैसे दे रहे हैं? क्या यह एक image_tag विफल रहा है या सीएसएस संदर्भ विफल रहा है?

यदि आपकी फ़ाइल यहां /app/assets/images/logos/opera_logo.png है तो निम्नलिखित संदर्भों को काम करना चाहिए। <%= image_tag('logos/opera_logo.png') %>

एक एससीएसएस फ़ाइल से::

एक html.erb फ़ाइल से

background: url(image_path("logos/opera_logo.png"))

http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets

+0

यह वही सोच है। – Dougui

+0

मैंने <% = image_tag ('logos/opera_logo.png')%> के साथ प्रयास किया। – Dougui

0

के अनुसार आपके Gemfile को यह जोड़ने और सर्वर को पुनः आरंभ, कोशिश: http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', "~> 3.2.3" 
    gem 'coffee-rails', "~> 3.2.1" 
    gem 'uglifier' 
end 
+0

यह वही सोच है – Dougui

13

मैंने एक ऐसी समस्या को मारा जो मैंने active_reload मणि को हटाकर हल किया।

+0

यह मेरे लिए तय है। धन्यवाद! – zaius

+1

रेल के लिए यह एक मुद्दा है 3.2 3.2 परियोजनाएं 3.2+ पर जा रही हैं ... परियोजना का मुखपृष्ठ कहता है कि 'active_reload' रेल 3.2 के आगे असंगत है। –

+0

खोज के कुछ घंटों के बाद - मुझे मिला। आपका बहुत बहुत धन्यवाद! –

0

रेल के लिए नया, लेकिन निर्देशिका में स्थित मेरी छवियों के लिए ../app/assets/images उदा। "rails.png" पृष्ठभूमि छवि के लिए उचित सीएसएस संदर्भ है: background: white url(rails.png) repeat-y; (विकल्प दिखाए गए)

भले ही यह छवियों फ़ोल्डर में है, रेल 3.2.6 (संस्करण जिसका मैं उपयोग कर रहा हूं) के साथ, आप ' निर्देशिका के छवियों को भाग नहीं डालते हैं।

संबंधित मुद्दे