AngularJS和Rails路由错误

我正在关注教程: https : //thinkster.io/angular-rails/

当我进入该部分时:将前端与资产管道集成,事情就会破裂; 网站陷入无限循环,并不断产生相同的错误。 我检查并重新检查了每一步。 请有人帮忙:

错误:

Started GET "/home/_home.html" for ::1 at 2015-04-17 11:55:43 -0400 ActionController::RoutingError (No route matches [GET] "/home/_home.html"): actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' web-console (2.1.2) lib/web_console/middleware.rb:37:in `call' actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app' railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.2.0) lib/rails/rack/logger.rb:20:in `call' actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.6.0) lib/rack/methodoverride.rb:22:in `call' rack (1.6.0) lib/rack/runtime.rb:18:in `call' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' rack (1.6.0) lib/rack/lock.rb:17:in `call' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call' rack (1.6.0) lib/rack/sendfile.rb:113:in `call' railties (4.2.0) lib/rails/engine.rb:518:in `call' railties (4.2.0) lib/rails/application.rb:164:in `call' rack (1.6.0) lib/rack/lock.rb:17:in `call' rack (1.6.0) lib/rack/content_length.rb:15:in `call' rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/routes/_route.html.erb (0.8ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.2ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (20.6ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/_markup.html.erb (0.3ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.3ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.5ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.4ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/console.js.erb within layouts/javascript (17.4ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/main.js.erb within layouts/javascript (0.3ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.6ms) Rendered /Users/MacKenzie/.rvm/gems/ruby-2.2.0/gems/web-console-2.1.2/lib/web_console/templates/index.html.erb (33.9ms) 

的Gemfile:

 source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.0' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc gem 'angular-rails-templates' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' # Access an IRB console on exception pages or by using  in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end 

application.js中:

 //= require angular //= require angular-rails-templates //= require angular-ui-router //= require_tree . 

routes.rb中:

 Rails.application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" # root 'welcome#index' root to: 'application#angular' end 

application.html.erb:

    FlapperNews      

app.js:

 angular.module('flapperNews', ['ui.router', 'templates']) .config([ '$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider .state('home', { url: '/home', templateUrl: 'home/_home.html', controller: 'MainCtrl' }) .state('posts', { url: '/posts/{id}', templateUrl: 'posts/_posts.html', controller: 'PostsCtrl' }); $urlRouterProvider.otherwise('home'); }]) 

应用程序/资产/ JavaScript的/家/ _home.html:

  
{{post.upvotes}} {{post.title}} {{post.title}} Comments

Add a new post

陷入同样的​​问题。 链轮问题。

解决方案: Angular Rails模板无法正常工作

在这里: http : //www.ademartutor.com/angular-rails-templates-gem-error-with-sprockets-3-0-o/

克里斯蒂安的回答对我有用。 要删除额外的链接,答案是添加

 gem 'sprockets', '2.12.3' 

到您的Gemfile然后运行包更新。

我有同样的问题。 运行bundle update通过安装更新​​版本的链轮和angular-rails-templates gems来修复它。

    Interesting Posts