Skip to content

Commit

Permalink
Merge pull request #26 from sherrimitchell/master
Browse files Browse the repository at this point in the history
Added user model, switched to Postgres database, added .gitignore file, removed test folder and started working on User.new action.
  • Loading branch information
nitsirk committed Oct 3, 2015
2 parents 734e8f9 + 9229afb commit fa5a56f
Show file tree
Hide file tree
Showing 291 changed files with 149 additions and 282 deletions.
12 changes: 12 additions & 0 deletions .gitignore
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
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'

# Using Postgres since we are deploying to Heroku
gem 'pg'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down
8 changes: 5 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ GEM
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
pg (0.18.2)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -127,8 +128,6 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sqlite3 (1.3.10-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
Expand Down Expand Up @@ -158,12 +157,15 @@ DEPENDENCIES
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
pg
rails (= 4.2.4)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3
turbolinks
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)

BUNDLED WITH
1.10.4
26 changes: 26 additions & 0 deletions app/controllers/users_controller.rb
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
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
35 changes: 35 additions & 0 deletions app/views/users/_form.html.erb
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 %>
4 changes: 4 additions & 0 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Yay! It worked."

<%= render "form" %>

File renamed without changes.
8 changes: 4 additions & 4 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
adapter: postgresql
pool: 5
timeout: 5000

development:
<<: *default
database: db/development.sqlite3
database: development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
database: test

production:
<<: *default
database: db/production.sqlite3
database: production
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
root 'dashboard#index'

root 'dashboard#index'

get 'users/new', to: 'users#new'
post '/users', to: 'users#create'
get '/users/:id', to: 'users#show'


# Example of regular route:
# get 'products/:id' => 'catalog#view'
Expand Down
18 changes: 18 additions & 0 deletions db/migrate/20150930235702_create_users.rb
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
31 changes: 31 additions & 0 deletions db/schema.rb
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
51 changes: 0 additions & 51 deletions log/development.log

This file was deleted.

Empty file removed test/controllers/.keep
Empty file.
9 changes: 0 additions & 9 deletions test/controllers/dashboard_controller_test.rb

This file was deleted.

Empty file removed test/fixtures/.keep
Empty file.
Empty file removed test/helpers/.keep
Empty file.
Empty file removed test/integration/.keep
Empty file.
Empty file removed test/mailers/.keep
Empty file.
Empty file removed test/models/.keep
Empty file.
10 changes: 0 additions & 10 deletions test/test_helper.rb

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

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.

Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

0 comments on commit fa5a56f

Please sign in to comment.