Skip to content

Instantly share code, notes, and snippets.

lifecycle do
state :unverified, :default => true
state :verified,:active, :inactive, :banned
create :signup, :available_to => "Guest",
:params => [:name, :real_name, :birthday, :email_address, :password, :password_confirmation],
:become => :unverified, :new_key => true do
if self.birthday.to_time < 18.years.ago
UserMailer.deliver_email_verification(self, lifecycle.key)
# --- Signup lifecycle --- #
lifecycle do
state :unverified, :default => true
state :verified,:active, :inactive, :banned
create :signup, :available_to => "Guest",
:params => [:name, :real_name, :birthday, :email_address, :password, :password_confirmation],
:become => :unverified, :new_key => true do
class UserMailer < ActionMailer::Base
def forgot_password(user, key)
host = Hobo::Controller.request_host
app_name = Hobo::Controller.app_name || host
@subject = "#{app_name} -- forgotten password"
@body = { :user => user, :key => key, :host => host, :app_name => app_name }
@recipients = user.email_address
@from = "no-reply@#{host}"
@sent_on = Time.now
class Bid < AR::Base
belongs_to :project
belongs_to :bidder, :creator => true, :class_name => "User"
def create_permitted?
return false if acting_user == project_owner
return false if project.already_bidded?(acting_user)
bidder_is? acting_user
end
def view_permitted?(attribute)
<extend tag="form" for="Picture">
<old-form enctype="multipart/form-data" merge>
<field-list: fields="name,description,license,notes,image" />
</old-form>
</extend>
<extend tag="card" for="Picture">
<card>
<h5><a /></h5>
<p>
<a><img src="#{this.image.url :thumbnail}" /></a>
<def tag="card" for="Comment" attrs="gravatar">
<div class="card linkable comment" param="default">
<h5 param="card-heading"><You:owner /> wrote <view:created_at format="on %B %d, %Y at %I:%M%p" param="card-timestamp" />:</h5>
<gravatar:owner unless="&gravatar == 'false'" rating="pg" size="50" param />
<p><view:body param="card-body" /></p>
<delete-button class="actions" param />
<report-content-link />
</div>
</def>
@kevinpfromnm
kevinpfromnm / unix permissions module.rb
Created August 10, 2010 19:44
Unix permissions example
UnixPermissions = classy_module do
belongs_to :owner, :creator => true, :class_name => "User"
belongs_to :group
fields do
group_read :boolean
group_write :boolean
group_destroy :boolean
everyone_read :boolean
everyone_write :boolean
@kevinpfromnm
kevinpfromnm / application.dryml
Created December 9, 2010 22:16
paperclip image example
<extend tag="form" for="Picture">
<old-form enctype="multipart/form-data" merge>
<field-list: fields="name,description,license,notes,image" />
</old-form>
</extend>
<extend tag="card" for="Picture">
<card>
<h5><a /></h5>
<p>
<a><img src="#{this.image.url :thumbnail}" /></a>
@kevinpfromnm
kevinpfromnm / comment.rb
Created January 11, 2011 00:11
Hobo model example
class Comment < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
body :text, :required
timestamps
end
belongs_to :commentable, :polymorphic => true, :counter_cache => true
@kevinpfromnm
kevinpfromnm / comment.rb
Created January 19, 2011 23:34
Comments extract
class Comment < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
body :text, :required
timestamps
end
belongs_to :commentable, :polymorphic => true, :counter_cache => true