我正在尝试将Angular集成到现有的Rails应用程序中。
我只想在我的应用的经过身份验证的部分中使用Angular。 user_profile等
我松散地关注这篇文章:
http://start.jcolemorrison.com/setting-up-an-angularjs-and-rails-4-1-project/
现在我正试图点击这个网址来测试它是否正常工作。然而,看起来它仍然在击中铁路。
有这样的路线。我收到这个错误:
的未定义方法`user_path'
配置/ routes.rb中
# resources :users
# match ':id', to: 'users#public_profile', via: 'get', as: :public_profile
# match '/users/:slug', to: 'users#show', via: 'get', as: :profile
match '/users/*path', to: 'users#index', via: 'get'
使用下面的路由我在控制台中收到此错误:
> GET http://127.0.0.1:3000/users/user_profile.html 404 (Not Found)
resources :users
match ':id', to: 'users#public_profile', via: 'get', as: :public_profile
match '/users/:slug', to: 'users#show', via: 'get', as: :profile
资产/ Javascript角/角度/ app.js.coffee
angular.module("myapp", [
"ngRoute"
"templates"
]).config ($routeProvider, $locationProvider) ->
console.log "app"
$routeProvider.when "/users/:id",
templateUrl: "user_profile.html"
controller: "UserCtrl"
$locationProvider.html5Mode true
return
资产/ Javascript角/角度/控制器/ users.js.coffee
angular.module("myapp").controller "UserCtrl", ($scope) ->
console.log "controller"
$scope.things = [
"Angular"
"Rails 4.1"
"Working"
"Together!!"
]
return
模板/用户/ user_profile.html.erb
<h1>The Home View!</h1>
<ul>
<li ng-repeat="thing in things">
{{thing}}
</li>
</ul>