似乎是我生成了一个新的控制器,然后生成了integration_test user_pages,然后整个事情变得混乱。我无法为我的生活弄清楚我做错了什么或从哪里开始。我甚至试图摧毁两者,同样的错误出来了。请帮忙!
Jordan-Poulton:Projects academy$ cd first_app/
Jordan-Poulton:first_app academy$ subl .
Jordan-Poulton:first_app academy$ rails generate controller Users new --no-test-framework
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
create app/controllers/users_controller.rb
route get "users/new"
invoke erb
create app/views/users
create app/views/users/new.html.erb
invoke helper
create app/helpers/users_helper.rb
invoke assets
invoke coffee
identical app/assets/javascripts/users.js.coffee
invoke scss
create app/assets/stylesheets/users.css.scss
Jordan-Poulton:first_app academy$ rails generate integration_test user_pages
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
invoke rspec
create spec/requests/user_pages_spec.rb
Jordan-Poulton:first_app academy$ rails s
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.2.4/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr in PATH, mode 040777
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:185:in `default_controller_and_action': missing :action (ArgumentError)
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:78:in `normalize_options!'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:61:in `initialize'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1304:in `new'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1304:in `add_route'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1284:in `decomposed_match'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1270:in `block in match'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1270:in `each'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:1270:in `match'
from /Users/academy/Projects/first_app/config/routes.rb:6:in `block in <top (required)>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:260:in `draw'
from /Users/academy/Projects/first_app/config/routes.rb:1:in `<top (required)>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `call'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `execute'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/academy/Projects/first_app/config/environment.rb:5:in `<top (required)>'
from /Users/academy/Projects/first_app/config.ru:3:in `require'
from /Users/academy/Projects/first_app/config.ru:3:in `block in <main>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/academy/Projects/first_app/config.ru:in `new'
from /Users/academy/Projects/first_app/config.ru:in `<main>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /Users/academy/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
答案 0 :(得分:0)
请检查您的控制器。内容应该是这个
#app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
end
end
和您的routes.rb
#config/routes.rb
FirstApp::Application.routes.draw do
get "users/new"
root to: 'pages#home'
在rails s之前运行以下命令,以防万一:
bundle install
bundle update
rake db:migrate
有时rake db:reset可能有所帮助,但这会破坏并重建您的开发环境中的数据库。