Browse Source

Start working on some basic MVC things.

old-ruby
Ben Kurtovic 9 years ago
parent
commit
f3ee286a8e
25 changed files with 147 additions and 69 deletions
  1. +13
    -22
      Gemfile
  2. +2
    -33
      Gemfile.lock
  3. +0
    -1
      app/assets/javascripts/application.js
  4. +2
    -0
      app/assets/javascripts/tools.js
  5. +2
    -0
      app/assets/javascripts/users.js
  6. +4
    -0
      app/assets/stylesheets/tools.css
  7. +4
    -0
      app/assets/stylesheets/users.css
  8. +0
    -5
      app/controllers/application_controller.rb
  9. +4
    -0
      app/controllers/tools_controller.rb
  10. +7
    -0
      app/controllers/users_controller.rb
  11. +5
    -0
      app/helpers/application_helper.rb
  12. +2
    -0
      app/helpers/tools_helper.rb
  13. +2
    -0
      app/helpers/users_helper.rb
  14. +2
    -0
      app/models/user.rb
  15. +4
    -4
      app/views/layouts/application.html.erb
  16. +2
    -0
      app/views/tools/index.html.erb
  17. +4
    -0
      app/views/users/create.html.erb
  18. +4
    -0
      app/views/users/login.html.erb
  19. +4
    -4
      config/routes.rb
  20. +12
    -0
      db/migrate/20150311175036_create_users.rb
  21. +25
    -0
      db/schema.rb
  22. +9
    -0
      test/controllers/tools_controller_test.rb
  23. +14
    -0
      test/controllers/users_controller_test.rb
  24. +13
    -0
      test/fixtures/users.yml
  25. +7
    -0
      test/models/user_test.rb

+ 13
- 22
Gemfile View File

@@ -1,37 +1,29 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'

# At this point, avoid using SASS or CoffeeScript
# gem 'sass-rails', '~> 5.0'
# gem 'coffee-rails', '~> 4.1.0'

# Avoid Turbolinks for now (https://github.com/rails/turbolinks)
# gem 'turbolinks'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
@@ -40,6 +32,5 @@ group :development, :test do
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
# gem 'spring'
end


+ 2
- 33
Gemfile.lock View File

@@ -44,13 +44,6 @@ GEM
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.9.1)
columnize (0.9.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
@@ -60,9 +53,6 @@ GEM
activesupport (>= 4.1.0)
hike (1.2.3)
i18n (0.7.0)
jbuilder (2.2.11)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
@@ -98,7 +88,7 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.0)
actionpack (= 4.2.0)
@@ -106,20 +96,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
sass (3.4.13)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
slop (3.6.0)
spring (1.3.3)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -131,10 +108,8 @@ GEM
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
@@ -151,14 +126,8 @@ PLATFORMS

DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.0)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)

+ 0
- 1
app/assets/javascripts/application.js View File

@@ -12,5 +12,4 @@
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

+ 2
- 0
app/assets/javascripts/tools.js View File

@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

+ 2
- 0
app/assets/javascripts/users.js View File

@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

+ 4
- 0
app/assets/stylesheets/tools.css View File

@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

+ 4
- 0
app/assets/stylesheets/users.css View File

@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

+ 0
- 5
app/controllers/application_controller.rb View File

@@ -2,9 +2,4 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

def hello
render text: "hello, world!"
end

end

+ 4
- 0
app/controllers/tools_controller.rb View File

@@ -0,0 +1,4 @@
class ToolsController < ApplicationController
def index
end
end

+ 7
- 0
app/controllers/users_controller.rb View File

@@ -0,0 +1,7 @@
class UsersController < ApplicationController
def create
end

def login
end
end

+ 5
- 0
app/helpers/application_helper.rb View File

@@ -1,2 +1,7 @@
module ApplicationHelper

def get_title(title = '')
base = 'Calefaction'
title.empty? ? base : "#{title} : #{base}"
end
end

+ 2
- 0
app/helpers/tools_helper.rb View File

@@ -0,0 +1,2 @@
module ToolsHelper
end

+ 2
- 0
app/helpers/users_helper.rb View File

@@ -0,0 +1,2 @@
module UsersHelper
end

+ 2
- 0
app/models/user.rb View File

@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end

+ 4
- 4
app/views/layouts/application.html.erb View File

@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Calefaction</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<title><%= get_title(yield(:title)) %></title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>



+ 2
- 0
app/views/tools/index.html.erb View File

@@ -0,0 +1,2 @@
<h1>Tools#index</h1>
<p>Find me in app/views/tools/index.html.erb</p>

+ 4
- 0
app/views/users/create.html.erb View File

@@ -0,0 +1,4 @@
<% provide(:title, 'Signup') %>

<h1>Users#create</h1>
<p>Find me in app/views/users/create.html.erb</p>

+ 4
- 0
app/views/users/login.html.erb View File

@@ -0,0 +1,4 @@
<% provide(:title, 'Login') %>

<h1>Users#login</h1>
<p>Find me in app/views/users/login.html.erb</p>

+ 4
- 4
config/routes.rb View File

@@ -1,9 +1,9 @@
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
root 'tools#index'

get '/signup' => 'users#create'
get '/login' => 'users#login'

# You can have the root of your site routed with "root"
root 'application#hello'

# Example of regular route:
# get 'products/:id' => 'catalog#view'


+ 12
- 0
db/migrate/20150311175036_create_users.rb View File

@@ -0,0 +1,12 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :password_hash
t.boolean :is_admin

t.timestamps null: false
end
end
end

+ 25
- 0
db/schema.rb View File

@@ -0,0 +1,25 @@
# 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: 20150311175036) do

create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "password_hash"
t.boolean "is_admin"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end

+ 9
- 0
test/controllers/tools_controller_test.rb View File

@@ -0,0 +1,9 @@
require 'test_helper'

class ToolsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end

end

+ 14
- 0
test/controllers/users_controller_test.rb View File

@@ -0,0 +1,14 @@
require 'test_helper'

class UsersControllerTest < ActionController::TestCase
test "should get create" do
get :create
assert_response :success
end

test "should get login" do
get :login
assert_response :success
end

end

+ 13
- 0
test/fixtures/users.yml View File

@@ -0,0 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString
email: MyString
password_hash: MyString
is_admin: false

two:
name: MyString
email: MyString
password_hash: MyString
is_admin: false

+ 7
- 0
test/models/user_test.rb View File

@@ -0,0 +1,7 @@
require 'test_helper'

class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

Loading…
Cancel
Save