>All Tutorials 
Ajax and .NET Ajax and .NET RSS XML
Ajax and ColdFusion Ajax and ColdFusion RSS XML
Ajax and Java Ajax and Java RSS XML
Ajax and PHP Ajax and PHP RSS XML
Ajax and SOA Ajax and SOA RSS XML
Ajax Goodies Ajax Goodies RSS XML
Ajax Tool Ajax Tool RSS XML
Facebook MockAjax Facebook MockAjax RSS XML
Google Web Toolkit Google Web Toolkit RSS XML
JavaScript Framework JavaScript Framework RSS XML
Ruby on Rails Ruby on Rails RSS XML
Technique Introduction Technique Introduction RSS XML
Without XMLHttpRequest Without XMLHttpRequest RSS XML
Yahoo! UI Yahoo! UI RSS XML

How to Create A Web 2.0 AJAX-Powered ShoutBox in 5 Minutes using Rails - rails ruby web create ajax shoutbox shoutline lines

 
Registered tutorials: 501
Registered Users: 39018



Rating: 3.33 out of 3 votes cast


  
Category: Ruby on Rails

How to Create A Web 2.0 AJAX-Powered ShoutBox in 5 Minutes using Rails

Digg this   Post to del.icio.us

Abstract: tutorial on how to set up a database system, create a table, create a Rails model, and do CRUD (Create-Read-Update-Delete) with it

As I promised yesterday, I won’t bore you with a tutorial on how to set up a database system, create a table, create a Rails model, and do CRUD (Create-Read-Update-Delete) with it. Instead, I’ll try to provide you with something more exciting (hopefully) for a first Rails app, a true Web 2.0 application: Ajax-powered Shout Box. All in 5 minutes, I promise. Sounds cool?

ShoutBoxes are somewhat popular these days, you know, these little boxes where anyone can post short messages that will be shown instantly on a web page. Sort of mini-chat feature, I guess. There are lots of ShoutBox scripts that you can find on the Internet, including (if not mostly) free ones. Let’s make YOU cooler than these guys by making YOUR own ShoutBox from scratch in about 5 minutes, the Rails way.

First, the obvious prerequisites are, you need to have Rails installed, and create a Rails project (I don’t care where you put it, as long as you can run script/server and you’ve tested that it works). Next time I won’t be that kind to tell you that, you know. For this project I won’t be using any database, even if it’s not that hard to setup a database system with Rails, this demo will run just fine without one. Unfortunately, that means our little demo will be somewhat useless if you want to actually use it without modification on a production site.

Minute 1

First, let’s create a non-ActiveRecord model class named ShoutLine which represents one line in the ShoutBox. Create a file named app/models/shout_line.rb and fill it with:

class ShoutLine
  attr_accessor :name, :text

  # Initializes a ShoutLine using some text
  def initialize(name, text)
    @name = name
    @text = text
  end

  # Returns all ShoutLines in memory
  def self.find_all
    @@lines
  end

  # Adds a ShoutLine to the top of the ShoutBox, returns the added ShoutLine
  def self.add(shoutLine)
    @@lines.unshift shoutLine
    shoutLine
  end

  # Initializes class variables
  @@lines = [ ShoutLine.new(’hendy’, ‘Welcome to my ShoutBox!’) ]

end


Read Full Tutorial...



Reviews:

Rate and Review This Site

No reviews yet


Statistic Information About this Resource:


Total Hits: 1273
Unique Hits: 892


  Daily Weekly Monthly
  Unique Total Unique Total Unique Total
Average 0.8 1.6 6.3 10.2 25.9 43.3
Current 0 0 5 11 14 24
Previous 1 1 7 11 33 55
Mar 11 2 5 7 10 29 44
Mar 10 0 0 6 14 11 13
Mar 9 2 5 7 10 40 62
Mar 8 0 0 12 18 33 66
Mar 7 0 0 0 0 12 19
Mar 6 0 0 9 14 23 32
Mar 5 2 4 0 0 32 54
Mar 4 1 1 10 14 32 64
Highest 7 15 22 36 71 84


Script Execution Time: 0.23334 | SQL Queries: 10 | Members: 501
Ajax Tutorial Top List - Powered by Aardvark Topsites PHP 5.1.2