-
-
Save DCarper/69ded6c1f814c8276d64 to your computer and use it in GitHub Desktop.
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 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 | |
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
def index | |
@search = @klass.search(params[:search]) | |
@records = @search.paginate :per_page => params[:per_page] || 20, :page => params[:page] || 1 | |
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
- 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 |
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 Membership < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :app, :polymorphic => true | |
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 Ownership < Membership | |
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
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 (users.email LIKE '%dj%') LIMIT 0, 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment