Tuesday, June 10, 2008

Deploying Rails Application in Morph AppSpace

Deploy your Rails applications in a fault-tolerant environment
with load balancers, private database, backups, and monitoring
— instantly expandable on the fly in case you get slashdotted.

Deploying your Rails application to a Morph AppSpace is a snap.
You create an account and then download a pre-configured Capistrano
recipe. Make a quick update of your SVN location and run the CAP command.
That’s it. Within a few minutes, your application is up and running,
ready for the world. (taken from Mor.ph)


I know you are quite familiar with Morph AppSpace
and this is just a quick simple steps on how to do deploy
your rails application in Morph.

Assumptions:


1. Your are using Subversion in your Rails application,
if not refer to this post.

2. You need to have an existing Morph Account, if none
you can sign-up for free here.

3. You have already installed Capistrano.

4. Deploying should be done in Linux environment (currently)

*Updated: I first tried deploying the application using Windows but it had errors during deployment. Since I had Linux and the deployment in Linux is pretty sweet with no errors at all, that's why I assumed it won't work for Windows.

But hey am wrong hehehe :) you need to tweak things in Windows (as usual) to make it work.

Steps:

1. Go to Morph Panel and create a new subscription

2. Click "Create Data Base". This will create an initial database setup
for your application.

3. Click "Download CAP File". This is the pre-configured Capistrano recipe
that Morph created for deploying your rails application.

4. Update the CAP(Capistrano) file, by setting your repository location.
e.g.
set :repository, nil => set :repository, 'http://svn.exist.com/svn/railsapp/trunk'

5. Run the CAP file.
>> cap -f morph_deploy.rb morph:deploy

a. This will get the application's code in svn.
b. If prompted for Morph Authentication, enter your Morph username/password.
c. Then this will upload the code in a S3.
d. If message is "Code upload is Done", your application is now ready for the world.

You can access it using the domain you specified in your subscription.
e.g http://your_apps_domain.morphexchange.com/
Your rails application is now available 24/7 via Morph AppSpace! Laughing

Example Rails App:

PANAGHIGALAAY

CODERS'BLOCK

SLUMMIES

Thursday, June 5, 2008

The END 0f J4VA!!!

I'd like to share this interesting link about the The END 0f J4VA

Wednesday, June 4, 2008

Our RoR App Deployed in Morph AppSpace



After almost a month of learning the curves of Ruby Language and Rails Framework

we successfully deployed our application in Morph AppSpace
here's our RoR App available 24/7: Coders'Block Application
Thanks to Morph!

About Coders'Block:
Lets developers paste their code online and share files to everyone. Codes Posted has Syntax Highlighter which depends on the programming language written. This is useful for when the developer needs help in debugging his code. Other developers can give their comments and suggestions on the posted items too!

Creators:
Diana, Gwen, and Gretchen


*Feel free to share you suggestions, we know it needs more tweaking hehehe it's a 5days work application so bear with us.

Other RoR Apps Deployed by other teams:
Panaghigalaay
Slummies

Monday, June 2, 2008

RestFul Authentication

I am an RoR noob myself and having different Rails plugins at my fingertips proves to be helpful.
If you want to add an authentication in your RoR application you can use Restful Authentication. Without you doing the code for logging feature so you have ample time for main features in your application.

Steps:
1. In your app root dir:
>>ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication

2. Then generate authenticated files:
>> ruby script/generate Authenticated Sessions User
( or if you want to activation add: --include-activation )

3. Edit the migration file if you want to add/remove fields and do the migration:
>> rake db:migrate

Viola! You have the logging feature added.
You can further update the models and add activation and an signup emailer if you want to. :)

Adding Captcha to your Application

Are you developing an RoR application and want to add CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) Authentication in it?

*Note
1. simple_captcha plugin is being used here if you want to use other plugin, you can find it in the net.
2. You must have RMagick installed. (This is a prerequisite.)

Here's the simple steps in adding a captcha image:

1. Type this command in your app root dir:
>> ruby script/plugin install svn://rubyforge.org/var/svn/expressica/plugins/simple_captcha


2. After successful installation.

>> rake simple_captcha:setup

(Am using Rails 2.x version for < 2.0 do

>> rake simple_captcha:setup_old)


3. Then do the migration.

>> rake db:migrate


4. Add this line of code to you config/routes.rb

map.simple_captcha '/simple_captcha/:action', :controller => 'simple_captcha'


5. Add this line in the file app/controllers/application.rb

include SimpleCaptcha::ControllerHelpers

6. In your view add:

<%= show_simple_captcha(:object=>"user") %>


7. In your model add:
apply_simple_captcha

8. Validating with captcha:
@user.valid_with_captcha?

9. Saving with captcha:
@user
.save_with_captcha

View Options

:label
provides the custom below the image, default is “(type the code from the image)”

:image_style
Provides the specific image style for the captcha image.
There are eight different styles available with the plugin as…

  • simply_blue
  • simply_red
  • simply_green
  • embosed_silver
  • all_black
  • distorted_black
  • charcoal_grey
  • almost_invisible

Default is ’simply_blye’
You can also specify ‘random’ to select the random image style.

:distortion
Handles the complexity of the image. The :distortion can be set to ‘low’, ‘medium’
or ‘high’. Default is ‘low’.

:code_type
Handles the text of the captcha image. Available options are ‘numeric’ or ‘alphabetic’.
Default is ‘alphabetic’.

:object
the name of the object of the model class, to implement the model based captcha.

How to change the CSS for SimpleCaptcha DOM elements ?
You can change the CSS of the SimpleCaptcha DOM elements as per your need in this file…
For Rails >= 2.0 the partial view file wiil reside as…
“/app/views/simple_captcha/_simple_captcha.erb”
For Rails < 2.0 the partial view file will reside as…
“/app/views/simple_captcha/_simple_captcha.rhtml”

View’s Examples

simple_captcha


for detailed info:
http://expressica.com/simple_captcha/