This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/types/{{type.id}}/delete" method="POST"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="output[duration]">Duration</label> | |
<select name="output[duration]"> | |
<option value="30"{{ ' selected="selected"' if output.duration == 30 }}>30 min</option> | |
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<option{{ ' selected="selected"' if output.date.month == i }}>{{ i }}</option> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on(":id") do |id| | |
output = Output[id] | |
on post, param("output") do |params| | |
date = Date.new(params["date_year"].to_i, params["date_month"].to_i, params["date_day"].to_i) | |
output.update(date: date, scale: params["scale"], duration: params["duration"]) | |
res.redirect("/outputs") | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% inputs = params[:inputs] | |
<h2><a href="/inputs/new">New Input</a></h2> | |
<h2>Your Input Types record</h2> | |
<table> | |
<thead> | |
<tr> | |
<th>Date</th> | |
<th>Category</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Migraine tracker - Inputs</h2> | |
<form action="/inputs" method="POST"> | |
<fieldset> | |
<label for="date">Date</label> | |
<select name="input[date_month]"> | |
% 1.upto(12).each do |i| | |
<option{{ ' selected="selected"' if Time.now.month == i }}>{{ i }}</option> | |
% end | |
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Output < Ohm::Model | |
reference :user, :User | |
attribute :date | |
attribute :duration | |
attribute :scale | |
attribute :comment | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Outputs < Cuba | |
define do | |
on("new") do | |
render("outputs/new", title: "Output") | |
end | |
on post, param("output") do |params| | |
date = Date.new(params["date_year"].to_i, params["date_month"].to_i, params["date_day"].to_i) | |
output = Output.create(date: date, scale: params["scale"], duration: params["duration"], user: current_user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Input < Ohm::Model | |
include Ohm::DataTypes | |
attribute :date, Type::Date | |
reference :user, :User | |
reference :type, "::Type" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Inputs < Cuba | |
define do | |
on("new") do | |
render("inputs/new", title: "New Input", types: Type.all) | |
end | |
on post, param("input") do |params| | |
date = Date.new(params["date_year"].to_i, params["date_month"].to_i, params["date_day"].to_i) | |
type = ::Type[params["type_id"]] | |
input = Input.create(date: date, type: type, user: current_user) |
NewerOlder