diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb new file mode 100644 index 000000000..4ccafe235 --- /dev/null +++ b/app/controllers/registrations_controller.rb @@ -0,0 +1,9 @@ +class RegistrationsController < Devise::RegistrationsController + + private + + def sign_up_params + params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation) + end + +end \ No newline at end of file diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 5a238ce6e..8c4da21cd 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -3,9 +3,20 @@ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> + +
+ <%= f.label :first_name %>
+ <%= f.text_field :first_name, autofocus: true %> +
+ +
+ <%= f.label :last_name %>
+ <%= f.text_field :last_name %> +
+
<%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> + <%= f.email_field :email %>
diff --git a/config/routes.rb b/config/routes.rb index eae8764ed..a1dbec65f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do - devise_for :users + devise_for :users, :controllers => { registrations: 'registrations' } + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/db/migrate/20150717164054_add_first_name_and_last_name_to_users.rb b/db/migrate/20150717164054_add_first_name_and_last_name_to_users.rb new file mode 100644 index 000000000..3be763bfd --- /dev/null +++ b/db/migrate/20150717164054_add_first_name_and_last_name_to_users.rb @@ -0,0 +1,6 @@ +class AddFirstNameAndLastNameToUsers < ActiveRecord::Migration + def change + add_column :users, :first_name, :string + add_column :users, :last_name, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 61fb86a58..466223bd8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150716174358) do +ActiveRecord::Schema.define(version: 20150717164054) do create_table "debates", force: :cascade do |t| t.string "title" @@ -34,6 +34,8 @@ ActiveRecord::Schema.define(version: 20150716174358) do t.string "last_sign_in_ip" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "first_name" + t.string "last_name" end add_index "users", ["email"], name: "index_users_on_email", unique: true