simple social networking with ruby on rails
DESCRIPTION
TRANSCRIPT
![Page 2: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/2.jpg)
Look, Ma! I’m on the Internets!
•delicious/kapowee •vimeo.com/bootstraps•flickr.com/zappowbang•twitter.com/jhenry•upcoming.org/jhenry•goodreads.com•yelp.com•linkedin.com•brightkite.com•friendfeed.com/puddlestomping
![Page 3: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/3.jpg)
Simple Social Networking With
Rails•What is a social network?
•Why build a social network?
•How might one build a social network?
•Hey, look, an example!
![Page 4: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/4.jpg)
What is a social network?
•Context of web applications
•Wikipedia has more on the broader, sociological concepts:
•http://en.wikipedia.org/wiki/Social_network
![Page 5: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/5.jpg)
What is a social network?
•Provides a Utility/Function (Content)
•Content is still king
•Content tends to be user-generated, controlled, and owned *
•Content interaction patterns (generating new content, sharing/republishing, modifying/remixing)
![Page 6: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/6.jpg)
What is a social network?
http://www.flickr.com/photos/vj_pdx/144902289/
![Page 7: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/7.jpg)
What is a social network?
•It's People!
•user relationships are many-to-many
•a blog is one-to-many
•User interaction patterns (friendships, fans, friends-of-friends)
![Page 8: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/8.jpg)
Why build a social network?
•What are you selling?
•Idea, product, theology, movement, etc.
•Why will your users come here?
![Page 9: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/9.jpg)
Why build a social network?
•What channels do you currently reach with your customers?
•How are you interacting with your customers?
•How do your customers interact with each other?
•How do your customers interact with their customers and others around them?
![Page 10: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/10.jpg)
Why build a social network?
•The evolution of the newsletter
•newsletters -> email lists -> blogs -> social networks?
![Page 11: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/11.jpg)
Why build a social network?
•It's fun!
•Crowdsourcing
•Think small - it doesn't have to be the next Facebook.
•Put The Service and The Community back in community service
•Scratch that itch
![Page 12: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/12.jpg)
How do you build a social network?
•Join as many as you can!
•Get a feel for what others are doing
•Consider this an education in UX/UI
•Reading blogs or books will help you become a better writer, so...
•Using these applications will inform your development process
![Page 13: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/13.jpg)
How do you build a social network?
•What will our data look like?
•Users
•Relationships (friends/fans)
•Content
![Page 14: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/14.jpg)
Pre-Fab vs. Home Cookin'
•Building from Scratch
•It's not too far off from the build-a-blog in 5 minutes example
•Just need a few more models, right?
•Add in a few plugins....
![Page 15: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/15.jpg)
Home Cookin' - Example
Relationship
Text create_table :connections do |t| t.integer :person_id t.integer :contact_id t.integer :status t.timestamp :accepted_at t.timestamps end
create_table :connections do |t| t.integer :person_id t.integer :contact_id t.integer :status t.timestamp :accepted_at t.timestamps end
Insoshi's connections migrations:
![Page 16: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/16.jpg)
Home Cookin' - Example
Relationship
create_table :friendships do |t| t.integer "user_id", :null => false t.integer "friend_id", :null => false t.datetime "created_at" t.datetime "updated_at" t.timestampsend
create_table :friendships do |t| t.integer "user_id", :null => false t.integer "friend_id", :null => false t.datetime "created_at" t.datetime "updated_at" t.timestampsend
Daniel Fischer’s “Fischy friends” example:
![Page 17: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/17.jpg)
Home Cookin'
•A few plugins and tools for consideration:
•Paperclip
•acts_as_commentable
•acts_as_taggable_on
![Page 18: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/18.jpg)
Pre-Fabricated
•Refactoring other people's code is a great way to learn
•Leaves you with the time to focus on implementing features, etc
![Page 19: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/19.jpg)
Pre-Fabricated
•Community Engine "plugin"
•Insoshi platform
•Ning (furniture included!)
•Bort, etc (just the walls, please)
![Page 20: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/20.jpg)
Enter Insoshi
•Advantage: a lot of pieces are pre-biult
•galleries, forums, blogs, messaging, activity feeds, events
•Disadvantage: a lot of pieces are pre-built
•may be lots to change or retrofit
![Page 21: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/21.jpg)
Inshtalling Insoshi
•To sphinx or not to sphinx?
•installing sphinx on OSX is a pain - need to add symlink, i.e.:
• $ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
•To install without sphinx, just skip that part of the install process.
![Page 22: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/22.jpg)
Building on top of Insoshi
•Yaay, I've got tests, yaaay!
•Users and relationships already exist
•Choose a model(s) to repurpose as needed (i.e. for custom content)
•Build new model(s) for custom content and interactions
![Page 23: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/23.jpg)
Example App - MyEventCarbon
•App for attendees/promoters of local events:
•See the carbon footprint of their events
•Organize carpools
•Suggest bus routes and other alternatives
![Page 24: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/24.jpg)
Example App - MyEventCarbon
•Repurpose Insoshi's nascent event model
•Use Gmaps api for geocoding
•AMEE for carbon calculations (amee.com)
![Page 25: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/25.jpg)
Example App - MyEventCarbon•Plugins
•ym4r for embedding google maps
•rspec_response_enhancer - add more descriptive output to rspec
•Floppy-amee - for interacting with AMEE data
![Page 26: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/26.jpg)
Example App - MyEventCarbon
![Page 27: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/27.jpg)
Example App - MyEventCarbon
![Page 28: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/28.jpg)
Example App - MyEventCarbon
![Page 29: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/29.jpg)
Example App - MyEventCarbon
![Page 30: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/30.jpg)
Example App - MyEventCarbon
create_table "event_attendees", :force => true do |t| t.integer "person_id" t.integer "event_id" t.string "origin" t.string "distance" t.string "carbon" end
schema.rb
![Page 31: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/31.jpg)
Example App - MyEventCarbon
belongs_to :person has_many :event_attendees has_many :attendees, :through => :event_attendees, :source => :person, :select => "event_attendees.origin, event_attendees.distance, event_attendees.carbon, people.*"
app/models/event.rb
![Page 32: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/32.jpg)
Example App - MyEventCarbon
•Carpooling?
•How to build a carpooling feature in?
•What would schema look like?
![Page 33: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/33.jpg)
Example App - MyEventCarbon
create_table "communications", :force => true do |t| t.string "subject" t.text "content" t.integer "parent_id" t.integer "sender_id" t.integer "recipient_id" t.datetime "sender_deleted_at" t.datetime "sender_read_at" t.datetime "recipient_deleted_at" t.datetime "recipient_read_at" t.datetime "replied_at" t.string "type" t.datetime "created_at" t.datetime "updated_at" t.integer "conversation_id" end
You could modify an existing model:
... but that could impact other parts of the system.
![Page 34: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/34.jpg)
Example App - MyEventCarbon
class CreateCarpools < ActiveRecord::Migration def self.up create_table :carpools do |t| t.integer :person_id t.integer :contact_id t.integer :event_id t.integer :status t.timestamp :accepted_at
t.timestamps end
A new table might be more appropriate:
Duplicate the connections table, add an event_id and whatever other fields as
needed.
![Page 35: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/35.jpg)
Example App - MyEventCarbon
•Next steps
•Carpooling offering/accepting/tracking
•“Live” carbon calculations
•Pull events from other services (upcoming, eventful)
•Import ical files, RSS, microformats (hcal)
•Adding to activity feed
•backchannel integration
![Page 36: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/36.jpg)
Moving forward
•Your homework: Join some more social networks and start using them.
•They work best when people you know (that's us) are using them with you
•Join me! Some of my networks are listed at http://friendfeed.com/puddlestomping
![Page 37: Simple Social Networking with Ruby on Rails](https://reader036.vdocument.in/reader036/viewer/2022081413/549194bbb47959db5c8b470c/html5/thumbnails/37.jpg)
Sourced/Resourced• Wikipedia article on "Social Network"
http://en.wikipedia.org/wiki/Social_network
• Jim Neath > Building a Social Network Site in Rails: http://jimneath.org/2008/04/25/building-a-social-network-site-in-rails/
• MissingMethod > How To Build a Social Network with Ruby on Rails: http://www.missingmethod.com/2007/01/08/how-to-build-a-social-network-with-ruby-on-rails/
• Friendship model examples & self referential models:
• Dan Fischer > Fischyfriends: http://github.com/dfischer/fischyfriends/tree/master
• Josh Susser > Self-referential has_many :through associations: http://blog.hasmanythrough.com/2007/10/30/self-referential-has-many-through
• Installing sphinx on OSX: http://www.sparkboxx.com/sparkboxx/2008/10/installing-ultr.html