Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9708e28
added skeleton
yandrew Feb 7, 2015
c873fd8
add routes file
yandrew Feb 8, 2015
90700f7
seed file with model, make, and year of cars
yandrew Feb 8, 2015
e3f617b
added some helper methods and add associations
yandrew Feb 8, 2015
df55c10
added restful routes format, they're still mostly empty though.
yandrew Feb 8, 2015
0613ee1
added rspec test file
yandrew Feb 8, 2015
608d674
add new views pages and forms for login page, but not working yet.
yandrew Feb 8, 2015
351f965
able to login and verify password with encryption, and added redirect…
yandrew Feb 8, 2015
9c0ddac
changed session delete to :current_user, adding welcome message to us…
yandrew Feb 8, 2015
f00de64
adding cars by make and models and their links, adding pricing view
yandrew Feb 8, 2015
45fe665
Merge pull request #1 from yandrew/Login_authentication
yandrew Feb 8, 2015
aeb0505
can register and login user, but not redirecting to cars page
yandrew Feb 8, 2015
7880f28
registration and login works, but registration does not redirect to t…
yandrew Feb 9, 2015
4704e73
registration redirects to login page correctly
yandrew Feb 9, 2015
8508d65
fixed some spacing
yandrew Feb 9, 2015
c623633
Merge pull request #3 from yandrew/registration
yandrew Feb 9, 2015
608b043
can add prices, but can't edit or click on prices yet..
yandrew Feb 9, 2015
6066aa8
working inidividual price links and puts the user who submittted it.
yandrew Feb 9, 2015
6194572
can edit prices, but not need to change it so you can't edit other pe…
yandrew Feb 9, 2015
9c1bf4c
able to edit and made it so you can't edit other peoples prices, and …
yandrew Feb 9, 2015
6ccf3ba
can delete now with no problems
yandrew Feb 9, 2015
30a2de6
deleted view own prices link
yandrew Feb 9, 2015
086a514
Merge pull request #4 from yandrew/add_delete_edit_prices
yandrew Feb 9, 2015
d8938ce
most of html css finished to mvp
yandrew Feb 9, 2015
73d6988
Merge pull request #5 from yandrew/html_css
yandrew Feb 9, 2015
b39e609
changed readme and removed one faker
yandrew Feb 9, 2015
683f402
deleted old code and add validations for cars
yandrew Feb 9, 2015
78e4fc1
adding: included Bcrypt because it was accidently deleted
yandrew Feb 9, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### v0.1.0
* Integrate rspec
* Add rake db:reset task
* Upgrade rake to 10.1.0
* Upgrade sinatra to 1.4.3
* Upgrade sinatra-contrib to 1.4.1

### v.0.1.1
* Implement a basic class and spec to exercise it
* Relocate misplaced comma set
* Convert models/README to Markdown
* Correct misusue of e.g.
* Convert helpers/README to Markdown
* Implement a "em" helper for reference; improve README
30 changes: 30 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
source 'https://rubygems.org'
ruby '2.0.0'

# PostgreSQL driver
gem 'pg'

# Sinatra driver
gem 'sinatra'
gem 'sinatra-contrib'

gem 'activesupport', '~>4.1'
gem 'activerecord', '~>4.1'

gem 'rake'

gem 'shotgun'

gem 'bcrypt'
gem 'faker'

group :test do
gem 'shoulda-matchers'
gem 'rack-test'
gem 'rspec'
gem 'capybara'
end

group :test, :development do
gem 'factory_girl'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factory_girl should only be used in test

end
94 changes: 94 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.1.1)
activesupport (= 4.1.1)
builder (~> 3.1)
activerecord (4.1.1)
activemodel (= 4.1.1)
activesupport (= 4.1.1)
arel (~> 5.0.0)
activesupport (4.1.1)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
backports (3.6.0)
bcrypt (3.1.10)
builder (3.2.2)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
diff-lcs (1.2.5)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
faker (1.3.0)
i18n (~> 0.5)
i18n (0.6.9)
json (1.8.1)
mime-types (2.3)
mini_portile (0.6.0)
minitest (5.3.4)
multi_json (1.10.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
pg (0.17.1)
rack (1.5.2)
rack-protection (1.5.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rake (10.3.2)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
shotgun (0.9)
rack (>= 1.0)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sinatra-contrib (1.4.2)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (1.2.0)
thread_safe (~> 0.1)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 4.1)
activesupport (~> 4.1)
bcrypt
capybara
factory_girl
faker
pg
rack-test
rake
rspec
shotgun
shoulda-matchers
sinatra
sinatra-contrib
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
This repo should be used to hold your phase 2, week 1 passion project.

see more about [portfolio challenges and passion projects here](../../../phase-2-guide/blob/sf/portfolio_challenges.md)

### Quickstart

1. `bundle install`
2. `bundle exec shotgun config.ru`
3. `bundle exec rake db:create`
4. `bundle exec rake db:migrate`
5. `bundle exec rake db:seed`
6. [Local host page](http://localhost:9393/)

These tasks might not need `bundle exec` prepended to it

### A website for community sharing of Car Costs

1. Website has authentication and authorizations with login and registration
2. Website has a many to many relationship with Users, Prices and Cars.
3. Website uses activerecord CRUD to create, read, update and delete prices.
4. Website has validations and error handling.
5. Website uses html and css.
6. Website uses Sinatra for routing.


## by Andrew Yan
141 changes: 141 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
require 'rake'

require ::File.expand_path('../config/environment', __FILE__)

# Include all of ActiveSupport's core class extensions, e.g., String#camelize
require 'active_support/core_ext'

namespace :generate do
desc "Create an empty model in app/models, e.g., rake generate:model NAME=User"
task :model do
unless ENV.has_key?('NAME')
raise "Must specificy model name, e.g., rake generate:model NAME=User"
end

model_name = ENV['NAME'].camelize
model_filename = ENV['NAME'].underscore + '.rb'
model_path = APP_ROOT.join('app', 'models', model_filename)

if File.exist?(model_path)
raise "ERROR: Model file '#{model_path}' already exists"
end

puts "Creating #{model_path}"
File.open(model_path, 'w+') do |f|
f.write(<<-EOF.strip_heredoc)
class #{model_name} < ActiveRecord::Base
# Remember to create a migration!
end
EOF
end
end

desc "Create an empty migration in db/migrate, e.g., rake generate:migration NAME=create_tasks"
task :migration do
unless ENV.has_key?('NAME')
raise "Must specificy migration name, e.g., rake generate:migration NAME=create_tasks"
end

name = ENV['NAME'].camelize
filename = "%s_%s.rb" % [Time.now.strftime('%Y%m%d%H%M%S'), ENV['NAME'].underscore]
path = APP_ROOT.join('db', 'migrate', filename)

if File.exist?(path)
raise "ERROR: File '#{path}' already exists"
end

puts "Creating #{path}"
File.open(path, 'w+') do |f|
f.write(<<-EOF.strip_heredoc)
class #{name} < ActiveRecord::Migration
def change
end
end
EOF
end
end

desc "Create an empty model spec in spec, e.g., rake generate:spec NAME=user"
task :spec do
unless ENV.has_key?('NAME')
raise "Must specificy migration name, e.g., rake generate:spec NAME=user"
end

name = ENV['NAME'].camelize
filename = "%s_spec.rb" % ENV['NAME'].underscore
path = APP_ROOT.join('spec', filename)

if File.exist?(path)
raise "ERROR: File '#{path}' already exists"
end

puts "Creating #{path}"
File.open(path, 'w+') do |f|
f.write(<<-EOF.strip_heredoc)
require 'spec_helper'

describe #{name} do
pending "add some examples to (or delete) #{__FILE__}"
end
EOF
end
end

end

namespace :db do
desc "Drop, create, and migrate the database"
task :reset => [:drop, :create, :migrate]

desc "Create the databases at #{DB_NAME}"
task :create do
puts "Creating development and test databases if they don't exist..."
system("createdb #{APP_NAME}_development && createdb #{APP_NAME}_test")
end

desc "Drop the database at #{DB_NAME}"
task :drop do
puts "Dropping development and test databases..."
system("dropdb #{APP_NAME}_development && dropdb #{APP_NAME}_test")
end

desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
task :migrate do
ActiveRecord::Migrator.migrations_paths << File.dirname(__FILE__) + 'db/migrate'
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
end
end

desc "rollback your migration--use STEP=number to step back multiple times"
task :rollback do
step = (ENV['STEP'] || 1).to_i
ActiveRecord::Migrator.rollback('db/migrate', step)
Rake::Task['db:version'].invoke if Rake::Task['db:version']
end

desc "Populate the database with dummy data by running db/seeds.rb"
task :seed do
require APP_ROOT.join('db', 'seeds.rb')
end

desc "Returns the current schema version number"
task :version do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end

namespace :test do
desc "Migrate test database"
task :prepare do
system "rake db:migrate RACK_ENV=test"
end
end
end

desc 'Start IRB with application environment loaded'
task "console" do
exec "irb -r./config/environment"
end

task :default => :spec
Empty file added app/controllers/.gitkeep
Empty file.
Loading