Skip to content

Instantly share code, notes, and snippets.

@bobbypage
Created May 29, 2012 00:45
Show Gist options
  • Save bobbypage/2821923 to your computer and use it in GitHub Desktop.
Save bobbypage/2821923 to your computer and use it in GitHub Desktop.
#user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
has_many :apps, :campaigns
end
#app.rb
class App < ActiveRecord::Base
attr_accessible :name, :promo_code_list, :user_id
has_many :campaigns
has_many :promo_codes
belongs_to :user
end
#campaign.rb
class Campaign < ActiveRecord::Base
belongs_to :app
attr_accessible :name, :app_id, :promo_code_count
end
#campaigns_controller.rb
class CampaignsController < ApplicationController
# GET /campaigns
# GET /campaigns.json
before_filter :authenticate_user!
def index
@campaigns = Campaign.all
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment