Wednesday, May 5, 2010

Workshop 6: Enjoying the Ride: Web framework alternatives, scalability and flexibility

Topic objectives

Upon the completion of this workshop, developers or managers should be able to:
· Discuss and analyse the latest Web framework technologies based upon experiences so far with Ruby on Rails
· Identify and evaluate challenges and opportunities concerning the use of the latest Web 2.0 technologies and to ‘benchmark’ (compare) other alternatives;
· Discuss and evaluate current Ruby on Rails framework and the alternative emerging technologies.
· Evaluate and devise scalability, flexibility, capacity planning and performance testing strategies for conducting e-commerce.
· Deploy Web 2.0 or later technology in their business environments such as the ideas and methods of the ‘RailsSpace’ approach to the OTBS
· Think critically and analytically when exposed to new technologies.
· Share your findings with your peers and examine what the other team is doing.

DEVELOPER’S THREAD (RED team)

To Do:

Developers may continue to build upon work with the OTBS using the topic reading to help with user registration and advanced login features from Hartl et al (2008). Some examples of work to do includes:

o generating a controller and an action by adding a method(s) to a controller;
o creating a view template for each action and to link to actions from views;
o using AJAX to improve the user experience;

Share your success by posting progress comments and links etc to the Developers sub-forum site that has been set up for the Red team.

Step 1: Create the OTBS application with mySQL as database in Rails.

C:\Ruby>rails OTBS –d mysql
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log


Step 2: Modify the database.yml to point to database “Taxi”

development:
adapter: mysql
encoding: utf8
database: taxi
pool: 5
username: root
password:
host: localhost

test:
adapter: mysql
encoding: utf8
database: taxi
pool: 5
username: root
password:
host: localhost

production:
adapter: mysql
encoding: utf8
database: taxi
pool: 5
username: root
password:
host: localhost


Step 3: Generate the “User” model

C:\Ruby\otbs>ruby script/generate model user --skip-migration
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/user.rb
create test/unit/user_test.rb
create test/fixtures/users.yml


Step 4: Generate the “User” controller with views “login”, “private” and “register”

C:\Ruby\otbs>ruby script/generate controller user login private register
exists app/controllers/
exists app/helpers/
create app/views/user
exists test/functional/
create test/unit/helpers/
create app/controllers/user_controller.rb
create test/functional/user_controller_test.rb
create app/helpers/user_helper.rb
create test/unit/helpers/user_helper_test.rb
create app/views/user/login.html.erb
create app/views/user/private.html.erb
create app/views/user/register.html.erb


Step 5: Modify the login.html.erb, private.html.erb and register.html.erb as follows:


Step 6: Modify the user_controller.rb as follows





Step 7: Create the database name “Taxi” in mySQL and table name “Users” with “id” as the primary key, “user_name” and “password” fields





Step 8: Start the web server

C:\Ruby\otbs>ruby script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-05-26 09:45:56] INFO WEBrick 1.3.1
[2010-05-26 09:45:56] INFO ruby 1.8.7 (2010-01-10) [i386-mingw32]
[2010-05-26 09:45:56] INFO WEBrick::HTTPServer#start: pid=4848 port=3000



Step 9: Verfiy if the project successful connecting the database by visiting http://localhost:3000/




Step 10: Visit http://localhost:3000/user/login. Click register to go to the register page to register new account for first logon.




Step 11: Type in User Name and Password and click REGISTER to verify the “adduser” controller


Step 12: Acknowledgement page checked for successful registration.



Step 13: Go mySQL to verify the new User Name and Password are created in the “User” table




Step 14: Type in a wrong User Name or Password to verify the “authenticate” function.




Step 15: Type in the correct User Name and Password and the taxi ordering page appears with greeting message “Welcome,




Step 16: After finish ordering a taxi, click logout to reset the session and redirect to login page with thank you message.





Reference

StackOverflow. (2010). Ruby on rails connection problem. Retrieved at 6 May, 2010, from http://stackoverflow.com/questions/1343500/ruby-on-rails-connection-problem

Devarticles. (2010). Ruby-on-Rails. Retrieved at 8 May, 2010, from http://www.devarticles.com/c/a/Ruby-on-Rails/Login-Systems-and-More-with-Ruby-on-Rails/

Visionmasterdesigns. (2010). Tutorial: Create a login system in Ruby on Rails Retrieved at May 8, 2010, from http://visionmasterdesigns.com/tutorial-create-a-login-system-in-ruby-on-rails/

Marklunds. (2010). Active Record Basics. Retrieved at 12 May, 2010, from http://marklunds.com/s5/rails101/html/active_record_basics.html

TheRegister. (2010). Ruby on Rails Part 2. Retrieved at 10 May, 2010, from http://www.theregister.co.uk/2006/07/17/ruby_rails_part2/


No comments:

Post a Comment