Colin Stodd
2014-Apr-11 18:37 UTC
Michael Hartl's ROR Tutorial: CH 7 Sign up form ISSUES!!!
So I've gone over this tutorial, literally recreated the app 4 times but I
keep getting stuck at the create user with a form in Ch 7. Rails 3 edition.
From what I can tell, there is no action (Post) being created when I click
on the submit button (no user being created, or errors being generated).
It reads it as (GET). And when I click the button, the URL shows my
authenticity-token....... blah blah...(not sure if that can help explain my
problem). Please can someone help me get past this. I have looked for
nearly weeks with no avail.
User.rb
```
*class User < ActiveRecord::Base attr_accessible :name, :email, :password,
:password_confirmation has_secure_password # Downcases all users email's
in the database before_save { email.downcase! } validates :name,
presence: true, length: { maximum: 50 } VALID_EMAIL_REGEX =
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX }, uniqueness: {
case_sensitive: false } # Creates and authenticates a secure password w.
password_digest. validates :password, presence: true, length: { minimum: 6
} validates :password_confirmation, presence: true*
*end*
```
routes.rb
```
* resources :users root to: "static_pages#home" match
"/signup", to:
"users#new" match "/about", to:
"static_pages#about" match "/contact",
to: "static_pages#contact" *
```
new.html.erb:
```
*<form class="form"> <div
class="container-fluid"> <div
class="row"> <div class="col-xs-7 col-md-7">
<%=
form_for(@user) do |f| %> <%= render
'shared/error_messages'
%> <%= f.label :name %> <%= f.text_field :name
%> <%= f.label :email %> <%= f.text_field :email
%> <%= f.label :password %> <%= f.password_field
:password %> <%= f.label :password_confirmation,
"Confirmation"
%> <%= f.password_field :password_confirmation %>
<%=
f.submit "Create my account", class: "btn btn-large
btn-primary"
%> <% end %> </div> </div>
</div></form*>
```
users.controller.rb
```
*class UsersController < ApplicationController def show @user =
User.find(params[:id]) end def new @user = User.new end def
create @user = User.new(params[:user]) if @user.save
flash[:success] = "Welcome personal web application!" redirect_to
@user else render 'new' end endend*
```
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/cbff6489-4d3f-4d4e-b322-0cbec9950774%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.