Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created September 13, 2012 16:46
Show Gist options
  • Save telagraphic/3715699 to your computer and use it in GitHub Desktop.
Save telagraphic/3715699 to your computer and use it in GitHub Desktop.
devise
class Day < ActiveRecord::Base
attr_accessible :sleep, :wake
has_one :habit, :dependent => :destroy
belongs_to :user
end
class Habit < ActiveRecord::Base
belongs_to :day
attr_accessible :energy, :mood, :overall
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :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
end
Life::Application.routes.draw do
devise_for :users do
resources :days
end
root :to => "Days#index"
resources :days do
resources :habits
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment