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*