old notes

sessions

#ruby #rails #models #sessions #users

Dopa-Mine App

Find Ways To Integrate:

  • j.query & AJAX calls to front end
  • pull json/cvs data & represent in dashboard
  • create API endpoints for grabbing daily summary?
  • chat function –> code sockets –> maybe have it make calls to a pybot api?
  • search function –> by tags/suggestions?

Steps.0

  1. Determine Models
  2. Build Schema/DB (remember joint tables)
  3. Validate associations
  4. Create Sessions
  5. Write tests

To-Do Organized by Pages:

1. Home/Login

  • redirect users to last visited page if they have to login here
  • sessions controller: add timed logouts?

2. User Dashboard @ users#home

  • remove dashboard controller?
  • represent data in graphs: %/24 hours of each type of dopamine
  • add today's activities + hours
  • represent progress of the week

3.

TO DO: map all the routes > models > views

Models

User has_and_belongs_to_many :activities has_many :comments

rails generate model User username:string email:string password_digest:string

Followed by rails db:migrate

Activity has_and_belongs_to_many :users has_many :dopamine_points has_many :comments

DopaminePoints belongs_to :activity belongs_to :user

Comment belongs_to :commented_on, polymorphic: true belongs_to :user

Rolling back migrations:

  • using rails db:rollback STEP=3 will roll back the database migration but it will not remove the generated models nor the migration schema instructions so you will have manually alter those to reflect the true database schema required.

Object syntax notes

@user object is initialized by User.new class + method

In console: Activity.find(1)