Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@DCarper /bracket.rb secret
Created Apr 8, 2011

class Bracket < ActiveRecord::Base
has_one :ownership, :as => :app
has_one :owner, :through => :ownership, :source => :user
has_many :memberships, :as => :app, :conditions => "status = '#{Membership::Status::MEMBER}' OR type = 'Ownership'"
has_many :members, :through => :memberships, :source => :user
def index
@search =[:search])
@records = @search.paginate :per_page => params[:per_page] || 20, :page => params[:page] || 1
- form_for @search, :html => {:id => 'bracket_search_form' }do |f|
= hidden_field_tag :format, 'admin'
= f.label :owner_email_like, 'Owner Email:'
= f.text_field :owner_email_like
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :app, :polymorphic => true
class Ownership < Membership
SELECT `brackets`.* FROM `brackets`
INNER JOIN `memberships` ON (`brackets`.`id` = `memberships`.`app_id` AND `memberships`.`app_type` = 'Bracket')
INNER JOIN `users` ON (`users`.`id` = `memberships`.`user_id`)
WHERE ( LIKE '%dj%') LIMIT 0, 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.