-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
Added user model, switched to Postgres database, added .gitignore file, removed test folder and started working on User.new action.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Files and folder listed here will not be included in version control/Git. | ||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore the default SQLite database. | ||
/db/*.sqlite3 | ||
/db/*.sqlite3-journal | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
!/log/.keep | ||
/tmp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class UsersController < ApplicationController | ||
|
||
def show | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
def new | ||
@user = User.new | ||
end | ||
|
||
def create | ||
@user = User.new(user_params) | ||
if @user.save | ||
flash[:notice] = 'User created successfully.' | ||
render :show | ||
else | ||
flash[:error] = 'Your entry was incorrect. Please try again.' | ||
end | ||
end | ||
|
||
private | ||
def user_params | ||
params.require(:user).permit(:first_name, :last_name, :email, :username, :password, | ||
:about_me, :avatar, :twitter, :github, :linkedin) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class User < ActiveRecord::Base | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<%= form_for(@user) do |f| %> | ||
|
||
<%= f.label :first_name %> | ||
<%= f.text_field :first_name, class: 'form-control' %> | ||
|
||
<%= f.label :last_name %> | ||
<%= f.text_field :last_name, class: 'form-control' %> | ||
|
||
<%= f.label :email %> | ||
<%= f.email_field :email, class: 'form-control' %> | ||
|
||
<%= f.label :username %> | ||
<%= f.text_field :username, class: 'form-control' %> | ||
|
||
<%= f.label :password %> | ||
<%= f.text_field :password, class: 'form-control' %> | ||
|
||
<%= f.label :about_me %> | ||
<%= f.text_field :about_me, class: 'form-control' %> | ||
|
||
<%= f.label :avatar %> | ||
<%= f.text_field :avatar, class: 'form-control' %> | ||
|
||
<%= f.label :twitter %> | ||
<%= f.text_field :twitter, class: 'form-control' %> | ||
|
||
<%= f.label :github %> | ||
<%= f.text_field :github, class: 'form-control' %> | ||
|
||
<%= f.label :linkedin %> | ||
<%= f.text_field :linkedin, class: 'form-control' %> | ||
|
||
<%= f.submit "Save changes", class: "btn btn-primary" %> | ||
|
||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"Yay! It worked." | ||
|
||
<%= render "form" %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CreateUsers < ActiveRecord::Migration | ||
def change | ||
create_table :users do |t| | ||
t.string :first_name | ||
t.string :last_name | ||
t.string :email | ||
t.string :username | ||
t.string :password | ||
t.text :about_me | ||
t.string :avatar | ||
t.string :twitter | ||
t.string :github | ||
t.string :linkedin | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# encoding: UTF-8 | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20150930235702) do | ||
|
||
create_table "users", force: :cascade do |t| | ||
t.string "first_name" | ||
t.string "last_name" | ||
t.string "email" | ||
t.string "username" | ||
t.string "password" | ||
t.text "about_me" | ||
t.string "avatar" | ||
t.string "twitter" | ||
t.string "github" | ||
t.string "linkedin" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.