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
<select> | |
% 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
<select> | |
% 1.upto(31).each do |i| | |
<option{{ ' selected="selected"' if Time.now.day == 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
<select> | |
% this_year = Time.now.year | |
% start_year = this_year - 2 | |
% start_year.upto(this_year).each do |i| | |
<option{{ ' selected="selected"' if Time.now.year == 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
require_relative "app" | |
Ohm.redis.call("FLUSHDB") | |
user = User.create(name: "Rocio Paez", email:"rocio.paez@me.com", password: "123456") | |
Type.create(category: "Food", name: "Chocolate", user: user) | |
Type.create(category: "Drink", name: "Acoholic beverages", user: 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 Mailer | |
extend Mote::Helpers | |
def self.render(template, params = {}) | |
return mote("./mails/#{ template }.mote", params) | |
end | |
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
on("forgot_password") do | |
on post, param("user") do |params| | |
user = User.fetch(params["email"]) | |
if user | |
text = Mailer.render("forgot_password", user: user) | |
Malone.deliver(from: "info@migraine.io", to: user.email, | |
subject: "Forgot Password", text: text) | |
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
require "malone" | |
Malone.connect(url: "smtp://localhost:2525", tls: false, domain: "migraine.io") | |
Dir["./services/**/*.rb"].each { |f| require(f) } |
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>Edit Profile</h2> | |
% update_profile = params[:update_profile] | |
% errors = update_profile.errors | |
% if errors | |
% if errors[:name].include?(:not_present) | |
<p>name is no present.</p> | |
% 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 UpdateProfile < Scrivener | |
attr_accessor :name | |
attr_accessor :email | |
attr_accessor :current_email | |
def validate | |
assert_present :name | |
if assert_email :email | |
if current_email != email |
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("profile") do | |
render("/profile", title: "Profile", current_user: current_user) | |
on post, param("user") do |params| | |
update_profile = UpdateProfile.new(params) | |
update_profile.current_email = current_user.email | |
on update_profile.valid? do | |
user = current_user | |
user.name = update_profile.name |
OlderNewer