Archive for the 'Features' Category

The Garbage Collector

The Garbage Collection feature has been introduced in Ruby recently. Though this useful feature is already available in other programming languages, Ruby made an effort to make it more efficient. Garbage pertains to the memory that has been allocated but not freed even if it is not needed anymore. An automatic mechanism for finding and clearing out the garbage is available in Ruby. It also frees memory in just a snap. The good outcome of this is the reduction of memory leaks. It cleans up the storage space in the memory effectively and avoids a lot of application boo-boos. The garbage collector is automatically tasked of freeing unused objects which makes it a more effective programming language.

Ruby and Rails – Parent/Child Relationship II

The number of programmers learning Ruby and Rails is increasing every year and that is a good sign! Some are having a hard time but some are actually having fun!

Ruby is a big help to a programmer to become a better developer by nourishing him with a better understanding on the code he is currently working on. Programming task is much more easier if the developer is quite familiar with the idioms and conventions available in Ruby. Debugging will also be an easy task for the programmer if he is working with Rails language.

Ruby on Rails is a very efficient way of creating and developing successful web applications in a short span of time compared to other programming and development environments.

Ruby and Rails – Parent/Child Relationship I

Have you realized that Ruby and Rails are mostly spoken together knowing the fact that they actually have individual differences and that they can go on without the other? For you information, Ruby is the base foundation of Rails. In other words, Ruby and Rails have this sort of parent-child relationship.

You can easily work with Rails if you have background with Ruby since both have similar conventions. We are not saying that you wouldn’t understand Rails without any knowledge on Ruby. You will save more precious time learning Rails if you are already familiar with Ruby. The code and functionality if Rails will be understood easily if you actually have knowledge on Ruby while studying Rails.

Features of Ruby Programming

Ruby Programming is an object-oriented program. It has four levels of variable scope which are: global, class, instance, and local. It has exemption handling. There are iterators and closures that are based on passing blocks of code. Ruby is also a native, Perl-like regular expressions at language level. The program features an automatic garbage collecting, operator overloading and is highly portable. It is has cooperative multi-threading on all platforms using green threads. It has a large standard library and DLL/shared library dynamic loading on most platforms. Ruby supports dependency injection and object runtime alteration. Ruby currently lacks full support for Unicode, though it has partial support for UTF-8.

Rails 2.3 Finally!!

railscreenshotThe much awaited upgrade to the much loved yet seemingly less loved Roby gets a full update with the full release of Rails 2.3 loaded with many updates and improvements to the rising underdog of the open-sourced world. Top features includes more built-in templates, making implementation of stripped down rails applications onto a skeleton framework easier, loaded with your default gem stacks, configuration settings and much much more. Nested forms have also become easier with improved built in handling allowing complex forms to be included easy as pie. Reusable application pieces in the engine completes the whole picture which allows developers and programmers to use, reuse and recycle working modules, easily including them into their current projects. Continue Reading »

Email on Rails

Image Source: joeydevilla.com

This is a guide on how to send message from your email using Ruby on Rails. First thing to do is to create a mailer for you to use in your application.

  • Open the command prompt window or your terminal
  • Run “./script/generate mailer MyMailer” from your Rails application home directory

Then you will have to configure the mailer. To be able to do this you should;

In your text editor, open config/environment.rb
Then add this script in the file’s bottom part

config.action_mailer.delivery_method = :smtp
ActionMailer::Base.server_settings = {
:address => “smtp.example.com”,
:port => 25,
:user_name => “username”,
:password => “password”,
:authentication => :plain
}

Rake like Make

Image Source: blogs.sun.com

Rake is a utility which is the same with Make in Unix. Rake is the Make of ruby or the Ruby Make. Luckily, Rails defines many tasks to help you. Some of the important commands which are supported by Ruby’s rake is

listed below;

  • rake db:fixtures:load - Load fixtures into the current environment’s database.
  • rake db:migrate - Migrate the database through scripts in db/migrate.
  • rake db:schema:dump - Create a db/schema.rb file that can be used against any DB.
  • rake db:schema:load - Load a schema.rb file into the database.
  • rake db:sessions:clear - Clear the sessions table.
  • rake db:sessions:create - Creates a sessions table for use with
    “CGI::Session::ActiveRecordStore”.
  • rake db:structure:dump - Dump the database structure to an SQL file.
  • rake db:test:clone - Recreate the test database from the current environment’s database.
  • rake db:test:clone_structure - Recreate the test databases from the development structure.
  • rake db:test:prepare - Prepare the test database and load the schema.
  • rake db:test:purge - Empty the test database.
  • rake doc:app -Build the app HTML Files.
  • rake doc:clobber_app - Remove rdoc products.
  • rake doc:clobber_plugins - Remove plugin documentation.
  • rake doc:clobber_rails - Remove rdoc products.
  • rake doc:plugins - Generate documation for all installed plugins.

First Steps through Ruby on Rails


Image Source:www.flickr.com

Classes, attributes, methods, and objects are the core of any Object-Oriented language. I am going to discuss how these classes, attributes, methods etc can be implemented in Ruby. There are two types of classes ‘close-ended’ and ‘open-ended’. If a class is close-ended, then new functionalities cannot be added to it without inheriting the class.
If a class is open-ended, then new functionalities can be added to it without inheriting it. Ruby is open-ended.
The class declared and defined just now is an empty class as it doesn’t contain any attributes or methods. You will notice that the procedure to define methods in ruby is very simple. def is the keyword used to define methods.
In ruby we don`t use brackets to define a set of code and we don`t use any semicolon at the end of the statements.

Why should you learn the Ruby Language?

Beginners nowadays usually starts with Java, C++ or C#. We must keep in mind that every programming language has its own strengths and weaknesses. The Ruby Language is still unknown to some students (and even programmers) but I believe that we should study this wonderful language because of the following reasons

The Ruby Language is one of the easiest to work with among languages I have encountered so far. According to some of Ruby devotees, it is a flexible language. You can easily extend class definitions and redefine anything and you can freely add built-in classes.

In a way, Ruby makes a programmer creative. Plumbing code is less required and you can concentrate on the problem itself. Blocks can help you out make the code efficient.

Ruby might still be considered as a “newbie” in the programming language world, but it’s getting a lot of attention lately due to the testimonials of its users. A Ruby Language can help you built web applications in an instant!

Copyright ©Basic Ruby On Rails Programming.