Tuesday, October 15, 2013

has_many & belongs_to

The Microposts Resource parallel the User Resources.

config/routes.rb
DemoApp::Application.routes.draw do
  resources:microposts
  resources:users
  .
  .
  .
end

Active Record

Forming associations between different data models with has_many and belongs_to.

app/models/user.rb
class User < ActiveRecord::Base
  has_many :microposts
end
app/models/micropost.rb
class Micropost < ActiveRecord::Base
  belongs_to  :user
  validates, :content, length: { maximum: 140 }
end
micropost_user_association


Hierarchy


demo_controller_inheritance

Middleman Blog

I am working on setting up a new Middleman blog to replace the jekll one I set up and mangled. http://jendiamond.github.io/ I was having a problem with having multiple versions of Middleman installed so I deleted them and started over with the oldest version that I have installed for  working on the RGSOC Team blog and the Bundler website. I may install RVM finally so I can use the newest version. I need some assistance and guidance. Time to check in with Cynthia. She said she'd show me RVM.
http://rubylearning.com/blog/2010/12/20/how-do-i-keep-multiple-ruby-projects-separate/

No comments:

Post a Comment