Live Notes For Refresh Ruby On Rails Workshop

> rails new blogpress

creates new directory contains:

– Gemfile – home to GEM dependencies
– app – where your models, views, and controllers
– config – this is where your configurations; routes, etc.
– db – database schema and migrations (SQLLite)
– log – development, test, and production logs
– public – web accessible directory, image, stylesheets, javascript, etc.
– Vendor – centralized location for 3rd party code from plugins to gem

> bundle install

bundler is a tool that installs required gems for your application. Bundler is able to determine dependencies and children without instructions from you

database configuration (database.yml)
defaults to sqlite, allows for mysql and postgreSQL

> rake db:create
– reads the datbase.yml file and creates db

rake, WTF?
Rake is a way to run tasks

rake -T = shows all tasks you can do

> rails server

> rm public/index.html

We don’t want this page displaying when visitors come to our blog

> rails generate controller home index

Generate a controller with only an index action to take the pklace of public/index.html

Update config/routes.rb to let the app know that our root should be
REMOVE get “home/index”
ADD root :to => “home#index”

Any rails file ends in .rb
Any rails view file is .erb


> rails generate scaffold Post author:string title:string content:text permalink:text

This file does ALL the work for you.
strings have a default length of 256 character
text has a default length of 1024 character (?)
float, decemial also other types

Scaffold creates full CRUD functionality for us, including our model, view, controller, and even our database mirgration

> rake db:migrate
Calls our self.up method to create the posts database table
Should be seeing “Listing posts”

> rails console

You can test pretty much anything right here.

(Use capital ‘P’ for the Posts object, not a particular post)

– You can add a .xml to the end to automatically spit out xml (rails by default spits out HTML)

– In your posts_controller.rb, add this for example to spit out JSON:
format.json { render :json => @posts }

Blog Comments:
> rails generate scaffold Comment post:references email:String content:text

> rake db:migrate


resources; comments
resources: posts


resources :posts do
resources :comments

/posts – /comments
/posts/1 – /comments/1
/posts/1/edit – /comments/1/edit

Changes now made urls like this:


@post = Post.find(params[:post_id])
@comments = @post.comments

We are going to use a Gem here
Add this to your Gemfile, at the end of your file (in your root):
gem ‘acts-as-taggable-on’

> bundle install

(might have to restart rails console before typing in the below:)
> rails generate acts_as_taggable_on:migration

> rake db:migrate


Don’t forget to update your show.html.erb to include:

<%= @post.tags %>

BLOG: Validation Options

:presence => true
:uniqueness => true
:numbericality => true
:length => { :minimum => 0, maximum => 2000 }
:format => { :with => /.*/ }
:inclusion => { :in => [1,2,3] }
:exclusion => { :in => [1,2,3] }
:acceptance = > true (deals with checkboxes)
:confirmation => true (deals with checkboxes)

validates :author, :presence => true, :length => {:maximum => 30 }
validates :title, :presence => true, :length => {:maximum => 100 }
validates :content, :presence => true

validates :email, :presence => true
validates :content, :presence => true

Blog: Validation

Basic HTTP authentications prompts users via a browser popup. This authentication lasts until the browser is closed.

Blog: Most Recent Posts

We want to display the top n posts on the main page, of course we’ll want the n more recent posts

Public Proposal For a South Florida Web Developer Conference

Update 12/23: Great feedback so far. I’ll be posting a follow-up within the next week.

A Little History… (Skip This If You Are In A Hurry)

For several years, South Florida has had the pleasure of being the host of numerous conferences (including the first official WordCamp Miami earlier this year at UM). For the past three years, that has included “Future of Web Apps” (FOWA) hosted by Carisonified. However, numerous potential attendees and developers were sadder to hear that in 2011, FOWA would be in Las Vegas. Nothing against FOWA (and I wish them well) or Las Vegas but that was about the only major annual conference that the majority of web developers and designers could enjoy.

Hence my proposal – South Florida needs it’s own annual conference deveoted to web design and development.

I brought this up on Twitter when I heard the news, and good some responses but now i’m desiring serious feedback. The endgame is hopefully to have a conference in Miami in early 2011.

The Pitch

This is my pitch to those interested in a one-day event in Miami (or Ft. Lauderdale if there is no Miami venue):

– The event would be for those who design, manage, or develop web sites/apps and mobile apps.
– The event will be for ANY skill level, even those who don’t consider themselves designers or developers.
– The event would be split into two tracks – one for coding, the other for design/UI/SEO/marketing.
– The first event will be structured similar to a “code camp” or WordCamp. Speakers and topics will be pre-selected and made available in plenty of time before the event starts. There’s a possibly of a “barcamp” open style block in the schedule time permitting.
– As with most camps and refresh-style meetings, speakers are not here to self promote themselves, their company, or their products. They are here to teach.
– A keynote is possible.
– Any speaker regardless of their hometown can submit a proposal but the overall event SHOULD represent/reflectt the vast local talent we have in South Florida.
– Cost of event will be VERY reasonable (think < $100 – and compare that to bigger conferences and you’ll see that certainly is reasonable).

What Do You Want To Learn?

Interested? Then this is what we need: suggestions for speakers and topics.

Here is a list to get started. Please leave a comment and let me know what YOU would like to speak about OR what you would like to see presented.

– CSS3
– Introduction to jQuery
– CMS Showdown: WordPress, Drupal, Joomla, ExpressionEngine
– Introduction to Ruby on Rails
– Introduction to PHP
– PHP Frameworks (Or Intro To MVC)
– Building Your First iPhone App
– Building Mobile Web Sites
– Spice Up Your Website With Custom Fonts
– SEO 101

I know alot of that is aimed towards programmers and developers – but that’s because I am primarily a developer myself. Any reasonable topic is fair game. And hence why i’m asking for your $0.02.

What’s Next?

During November, i’m going to gauge the interest level in a more official capacity and if things look good, start nailing down potential topics and speakers.

How About A Venue?

Admittingly this is not a strong suit of mine. If you have a suggestion for a venue and know someone “on the inside”, please let me know. Usually events like this take place at collegues or universities. Keep in mind that funding will be coming directly from ticket sales, so the less the venue costs the less the ticket prices will be.

We will also announce ways local companies can sponsor the event for VERY reasonable prices. Sponsorship costs would go back into paying for the event. Everything here is basically non-profit.

What Do You Think?

That’s my proposal. Now let me know what you think. What do you want to see at WebDevMiami2 2011?