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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

Search Discussions

  • Frederick Cheung at Apr 11, 2014 at 8:39 pm

    On Friday, April 11, 2014 7:37:53 PM UTC+1, Colin Stodd wrote:
    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.

    ```
    <form class="form">
    <div class="container-fluid">
    <div class="row">
    <div class="col-xs-7 col-md-7">
    <%= form_for(@user) do |f| %>

    Your error is here - you've got a form within a form which is invalid html

    Fred


    <%= 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
    end

    end

    ```
    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/50573603-5258-48f1-804e-8383d373ca9e%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Stodd at Apr 11, 2014 at 10:01 pm
    I wish I could buy you a drink of your choice Frederick. Thank you for
    taking the time to look over my post! It's truly appreciated!
    On Friday, April 11, 2014 4:39:42 PM UTC-4, Frederick Cheung wrote:
    On Friday, April 11, 2014 7:37:53 PM UTC+1, Colin Stodd wrote:
    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.
    ```
    <form class="form">
    <div class="container-fluid">
    <div class="row">
    <div class="col-xs-7 col-md-7">
    <%= form_for(@user) do |f| %>

    Your error is here - you've got a form within a form which is invalid html

    Fred


    <%= 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
    end

    end

    ```
    --
    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@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/53e0f3e9-7a9d-4758-b61d-e7936e7d778e%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 11, '14 at 8:36p
activeApr 11, '14 at 10:01p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Colin Stodd: 2 posts Frederick Cheung: 1 post

People

Translate

site design / logo © 2022 Grokbase