Archive for the 'Uncategorized' Category

Learning Ruby

As with any other computer language, writing codes, mostly using IRB, is the best way to learn Ruby. If you have written a number of lines, place it in a file and run it. After you’ve figured out how it works, learn about the unit testing framework, try to discover the machinery that makes it work. Another way is to get involve in discussions and if you come across unanswered questions, do research, deliberate and come up with an answer. It would also be helpful if you let the program reveal itself to you, accept it as a simple program and could give you a straightforward solution to a problem.

Ruby as a Programming Language

The Ruby language has been used for scripting jobs, but most often it is used as a general-purpose programming language. It can be used to write GUI applications and middle-tier server processes, as well as for managing server machines and databases. Ruby is also used for working with Web pages, interfacing to databases and producing dynamic content. Some clients are using it to write artificial intelligence and machine learning programs, and have been found to be useful as a means for exploratory mathematics and formatting book publications. It is a wonderful language for creating solutions in a variety of problem domains.

Ruby as ApplyScript Replacement?

With the recent developments going on between OS X and Ruby, A lot of Ruby addicts are convinced that Ruby has the potential to be the de-facto OS scripting language of choice within the next few years. A lot of programmers find AppleScript secretive or hideous enough to avoid it wherever possible. There’s an article recently that compares an AppleScript code and it’s ruby alternative:

The AppleScript Code:

tell application “TextEdit”
get paragraph 1 of document “Read Me”
end tell

The Ruby Alternative
app(’TextEdit‘).documents[’Read Me‘].paragraphs[1].get

In reality, AppleScript is much more easier to understand, but the Ruby version is easier to remember in terms of its construction and as long as you’re familiar with Ruby syntax, you won’t get lost.

Bottom’s Up

That is a development style that begins with the overall layout and ends with the details or nuances on how the web page works. It is best for visually intensive sites that need a lot of graphics but equally important is the way that visual layout translates to a well developed page. Keeping your pages clean and neat(without sacrificing layout/graphics) can be achieved with some nifty tools that come from many sources on the web. Developer forums allows people like you and me to get real world solutions and even snippets of codes to help us do the most common tasks. Common sense is the basis of such a well developed page for the headaches will surely come if you fail to properly do your page…

Plug-ins and Rails


Using plug-ins with Ruby on Rails is really not hard. In fact, it is quite easy to use plug-ins because it already has a very well developed plug-in. This means that plug-ins can be easily installed and used in the application. It is not unusual for a developer to use up to six plug-ins for every single Rails application.
Plug-ins are quite helpful because during the process of development, the plug-ins already have the code that you need ready. You won’t even have to write it yourself. This is one reason why developing on Rails is so fast and easy.

Productivity and Rails (1)

Rails can help you achieve a new level of productivity by combining the right elements in the right amounts. A number of the most important ingredients that make up Rails:

• Ruby – use the Ruby programming language and it’s unique design makes it easy to create domain-specific languages and to do metaprogramming. Rails takes full advantage of this.

• Full-stack MVC framework – a framework where Rails provides all the layers and they work together without an effort.

• Convention over configuration – Rails application uses few simple programming conventions that let it figure out everything by way of reflection and discovery.

The Ruby Language

Ruby is straightforward and easy to learn. Coding for tasks is simple and can be easily maintained. In Ruby programming things work out as you expect them to do, and no surprises will spring on you. It is a transparent language as it does not hide solutions behind syntax you have written and does not need support codes to get simple things done. Programs are expressed directly and elegantly, making coding faster and the programs readable.
It is quite astonishing that when you use Ruby, more codes can be done and it works at the first try. You will see very few syntax errors, no type violations, and far fewer bugs.

The Ruby on Rails Web Framework

Ruby on Rails is a framework for developing database-backed web applications using the Model-View-Control (MVC) pattern. Rails gives you a Ruby development environment, starting from the Ajax in the view, to the request and response in the controller, and to the domain model wrapping the database. Almost everyone from business startups to non-profits to enterprise organizations are using Rails. It is all about infrastructure, so it fits practically into any type of web application, be it software for collaboration, community, e-commerce, content management, statistics,or management. It works with a wide range of web servers and databases, just about any operating system.

Benefit of a Real Closure – What to Do with a Block Made into an Object

A closure can be reconverted into a block, so a closure can be used anywhere a block can be used. Closures are used to store the status of a block into an instance variable, once you convert a block into a closure, it is becomes an object that can by referenced by a variable. Just as they are used in other languages, closures can be passed around the object to customize behavior of methods. To pass some code to customize a method, just pass a block. But if you want to pass the same code to more than two methods — convert the block into a closure, and pass that closure object to multiple methods.

Rails Ecosystem

The Rails program includes a host of tools and extension methods:

Generators – special Rails method that make routine the making of models, controllers, etc.
Scaffolds – type of generator that automatically creates a simple set of incorporated functionality. They are used to maintain the CRUD views and controller actions for a specific model.
Gems – pack of Ruby codes
Rails plugins – similar to Gems but are directly established to a specific Rails application.
JavaScript frameworks are openly backed by Rails – the prototype and the scriptaculous.
RDoc and RI – devices for establishing and viewing program documentation.
Rails Console – makes available a command line setting for working directly with your application.

Next Page »

Copyright ©Basic Ruby On Rails Programming.