Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solo il #8

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ gem 'sinatra-contrib'

gem 'activesupport'
gem 'activerecord'
gem 'bcrypt-ruby'
gem 'bcrypt'
gem 'httparty'

gem 'rake'

Expand Down
114 changes: 61 additions & 53 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,83 +1,87 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
arel (~> 6.0)
activesupport (4.2.1)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
arel (~> 7.0)
activesupport (5.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
backports (3.6.4)
bcrypt (3.1.10)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
builder (3.2.2)
capybara (2.4.4)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
backports (3.7.0)
bcrypt (3.1.11)
capybara (2.13.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
concurrent-ruby (1.0.5)
database_cleaner (1.4.1)
diff-lcs (1.2.5)
factory_girl (4.5.0)
diff-lcs (1.3)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
faker (1.4.3)
faker (1.7.3)
i18n (~> 0.5)
i18n (0.7.0)
json (1.8.2)
mime-types (2.5)
mini_portile (0.6.2)
minitest (5.6.1)
multi_json (1.11.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pg (0.18.2)
rack (1.6.1)
httparty (0.15.5)
multi_xml (>= 0.5.2)
i18n (0.8.1)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.6.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
pg (0.20.0)
public_suffix (2.0.5)
rack (1.6.5)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
rake (12.0.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
shotgun (0.9.1)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
shotgun (0.9.2)
rack (>= 1.0)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
sinatra (1.4.6)
rack (~> 1.4)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra-contrib (1.4.2)
sinatra-contrib (1.4.7)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
thread_safe (0.3.5)
tilt (1.4.1)
tzinfo (1.2.2)
tilt (>= 1.3, < 3)
thread_safe (0.3.6)
tilt (2.0.7)
tzinfo (1.2.3)
thread_safe (~> 0.1)
xpath (2.0.0)
nokogiri (~> 1.3)
Expand All @@ -88,11 +92,12 @@ PLATFORMS
DEPENDENCIES
activerecord
activesupport
bcrypt-ruby
bcrypt
capybara
database_cleaner (~> 1.4.1)
factory_girl
faker
httparty
pg
rack-test
rake
Expand All @@ -101,3 +106,6 @@ DEPENDENCIES
shoulda-matchers
sinatra
sinatra-contrib

BUNDLED WITH
1.14.6
103 changes: 103 additions & 0 deletions Gemfile1.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
arel (~> 6.0)
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
backports (3.6.4)
bcrypt (3.1.10)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
builder (3.2.2)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
database_cleaner (1.4.1)
diff-lcs (1.2.5)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
faker (1.4.3)
i18n (~> 0.5)
i18n (0.7.0)
json (1.8.2)
mime-types (2.5)
mini_portile (0.6.2)
minitest (5.6.1)
multi_json (1.11.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pg (0.18.2)
rack (1.6.1)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
shotgun (0.9.1)
rack (>= 1.0)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
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.5)
tilt (1.4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
activerecord
activesupport
bcrypt-ruby
capybara
database_cleaner (~> 1.4.1)
factory_girl
faker
pg
rack-test
rake
rspec
shotgun
shoulda-matchers
sinatra
sinatra-contrib
11 changes: 0 additions & 11 deletions app/controllers/auth.rb

This file was deleted.

53 changes: 53 additions & 0 deletions app/controllers/forecasts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
get '/forecasts' do
@forecasts = Forecasts.all
end


get '/forecasts/new' do
erb '/forecasts/new'
end


post '/forecasts' do
@forecast = Forecasts.new(params[:forecast])
if @forecast.save
redirect "forecasts"
else
@errors = @forecast.full_messages
erb '/forecasts/new'
end
end



get '/forecasts/:id' do
@forecast = Forecast.find(params[:id])
# @text_messages = @forecast.text_messages
erb :'forecasts/show'
end


#Edit
get '/forecasts/:id/edit' do
@forecast = Forecast.find(params[:id])
erb :'restaurants/edit'
end

put '/forecasts/:id' do
@forecast = Forecast.find(params[:id])
@forecast.update_attributes(params[:forecast])
if @forecast.save
redirect "/"
else
@errors = @restaurant.errors.full_messages
erb :'forecasts/edit'
end
end

#Delete
delete '/forecast/:id' do
@forecast = Forecast.find(params[:id])
@forecast.destroy
redirect '/'
end

4 changes: 4 additions & 0 deletions app/controllers/index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
get '/' do
# @forecasts = Forecast.all
erb :'index'
end
22 changes: 22 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
get '/sessions/new' do
erb :'sessions/new'
end


post '/sessions' do
@user = User.where(username: params[:username]).first
if @user && @user.authenticate?(params[:password])
session[:id] = @user.id
redirect "/users/#{@user.id}"
else
@errors = []
@errors << "Incorrect username or password"
erb :'sessions/new'
end
end


delete '/sessions/:id' do
session[:id] = nil
redirect '/'
end
Loading