Skip to content

Instantly share code, notes, and snippets.

@Heavyblade
Created September 9, 2012 21:17
Show Gist options
  • Select an option

  • Save Heavyblade/3687359 to your computer and use it in GitHub Desktop.

Select an option

Save Heavyblade/3687359 to your computer and use it in GitHub Desktop.
class App < ActiveRecord::Base
attr_accessible :image, :name, :ram
has_many :versions
has_many :installations
belongs_to :user
validates_presence_of :name
mount_uploader :image, ApplogoUploader
def actual_version
versions.actual
end
def self.aviable_for_user(user_id)
user_apps = App.select("id").where(:user_id => user_id).map(&:id)
with_versions = Version.where(:app_id => user_apps, :default => true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment