Skip to content

Instantly share code, notes, and snippets.

<select>
% 1.upto(12).each do |i|
<option {{ ' selected="selected"' if Time.now.month == i }}>{{ i }}</option>
% end
</select>
<select>
% 1.upto(31).each do |i|
<option{{ ' selected="selected"' if Time.now.day == i }}>{{ i }}</option>
% end
</select>
<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>
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)
class Mailer
extend Mote::Helpers
def self.render(template, params = {})
return mote("./mails/#{ template }.mote", params)
end
end
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
require "malone"
Malone.connect(url: "smtp://localhost:2525", tls: false, domain: "migraine.io")
Dir["./services/**/*.rb"].each { |f| require(f) }
<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
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
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