开发者

Error following Michael Hartl's tutorial:

开发者 https://www.devze.com 2023-03-09 10:45 出处:网络
I\'ve been following Michael Hartl\'s rails tutorial but without testing (bad practice I know - I\'m completely new to web programming having only dabbled in HTML and CSS before). I\'ve reached the la

I've been following Michael Hartl's rails tutorial but without testing (bad practice I know - I'm completely new to web programming having only dabbled in HTML and CSS before). I've reached the last chapter but I'm having problems with the user signup form. It's rendering properly in the browser but on submit I get the message

No route matches "/users/new"

Everything seems to be as it should be in the routes.rb file, and by entering users/new directly into the browser I can navigate to the correct page (the signup form) - but can't create new users.

There doesn't seem to be anything missed out from Michael Hartl's code

I've checked out the users controller as I fig开发者_如何学Pythonured it must be something to do with the 'new' or 'create' actions. It might also have to do with the number of "swap" files that seem to be being created every time I edit a file with Vim. I'm completely ignorant about what this means, but perhaps it's screwing things up. I've left these intact in my github push so you can see my incompetence.

Thanks for any help you can give me!

Here's the routes.rb file (everything else is on github at https://github.com/jnwb2/the_app):

TheApp::Application.routes.draw do

resources :users do

member do

  get :following, :followers

end

end

resources :sessions, :only => [:new, :create, :destroy]

resources :microposts, :only => [:create, :destroy]

resources :relationships, :only => [:create, :destroy]

match '/contact', :to => 'pages#contact'

match '/about', :to => 'pages#about'

match '/help', :to => 'pages#help'

match '/signup', :to => 'users#new'

match '/signin', :to => 'sessions#new'

match '/signout', :to => 'sessions#destroy'

root :to => 'pages#home'

end


Found the answer. For one, i think you should stop following this tutorial. It seems to have a lot of bad practices going on. Try going to guides.rubyonrails.org instead. To fix your problem however, change line #8 in the users controller like so:

def new
  @title = "Sign up"
  @user = User.new
end

Sorry for all my extra comments from before, just ended up cloning your source to find the issue.

0

精彩评论

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