Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User has many residents.
- ## Resident Database
- class CreateResidents < ActiveRecord::Migration
- def self.up
- create_table :residents do |t|
- t.integer :user_id,
- :house_id
- t.boolean :currently, :null => false, :default => true
- t.timestamps
- end
- end
- def self.down
- drop_table :residents
- end
- end
- ## Resident Model
- class Resident < ActiveRecord::Base
- belongs_to :user
- belongs_to :house
- def current
- end
- def self.has_resident? facebook_uid
- user = User.find_by_facebook_uid(facebook_uid)
- if user == nil
- false
- else
- find_by_user_id(user.id, :conditions => "currently = true") == nil ? false : true
- end
- end
- end
Add Comment
Please, Sign In to add comment