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

dan/laura sinatra-todo list #8

Open
wants to merge 5 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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATABASE_URL=sqlite3:///db/todo.sqlite3
DATABASE_URL=sqlite3:///db/todo.sqlite3
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ruby "1.9.3"

gem 'sinatra'
gem 'sinatra-activerecord'
gem 'dotenv'


group :production, :staging do
Expand All @@ -21,8 +22,7 @@ end

group :development, :test do
# Heroku ignores development/test groups
# https://devcenter.heroku.com/articles/getting-started-with-ruby#runtime-dependencies-on-development-test-gems
gem 'dotenv'
# https://devcenter.heroku.com/articles/getting-started-with-ruby#runtime-dependencies-on-development-test-gem
gem 'sqlite3'
gem 'shotgun'
gem 'capybara'
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec ruby todo_app.rb -p $PORT
2 changes: 1 addition & 1 deletion models/todo.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Todo < ActiveRecord::Base

end
2 changes: 1 addition & 1 deletion spec/features/guest_completes_todo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

feature "Guest completes todo" do
xscenario "Completing a todo removes it from the page" do
scenario "Completing a todo removes it from the page" do
call_mother = Todo.create(name: "Call mother")
Todo.create(name: "Pet a dog")
visit '/'
Expand Down
8 changes: 7 additions & 1 deletion todo_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
require 'dotenv'
Dotenv.load

set :database, ENV['DATABASE_URL']
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || postgres://localhost/todo')

get '/' do
@todos = Todo.all
erb :index
end

post '/todos' do
Todo.create(:todo => params["todo"])
redirect '/'
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between redirect '/' and erb :index?

end
14 changes: 13 additions & 1 deletion views/index.erb
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
<h1>Here's all the things to do:</h1>
<form method="POST" action="/todos">
<label> New Todo:
<input name="todo" type="text"/>
</label>

<input type="submit"/>
</form>

<h1>Here's all the things to do:</h1>

<% @todos.each do |note| %>
<li style="list-style:none;margin-bottom:10px;margin-left: 5px;"> <%= note.todo %> </li>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend using a stylesheet instead of putting styles inline.

<% end %>