Ruby on DON’t REPEAT YOURSELF (DRY) philosophy

Also known as Single Point of Truth, “don’t repeat yourself” or DRY is a process philosophy seeking to reduce duplication especially in computing. This philosophy stress on that information should not be duplicated because it makes the change more difficult, it can lessen clarity and may lead to inconsistency. DRY is from Andy Hunt’s and Dave Thomas’ principle in the book of Pragmatic Programmer. A revision of any single element of a system does not alter other logically-unrelated elements when the DRY principle is effectively applied. Moreover, elements are kept in sync because elements that are logically related all change predictably and evenly.

Posted in Basics | Tagged , | Comments closed

Rails technicality

rails11.jpg

Rails uses the Model-View-Controller (MVC) architecture just like many other contemporary web frameworks for organizing application programming. Rails is remarkable for its widespread use of the JavaScript libraries Prototype and Script.aculo.us that is significantly used for for Ajax and its graphical interface. And because of Rails’ “out of the box” scaffolding, it can promptly generate most of the models and views necessary for a basic website. Rails has useful development tools built in or already installed like the WEBrick web server and the Rake build system. Rails also originally supported lightweight SOAP for web services and it was later replaced by RESTful web services as it significantly altered to version 1.2.

Posted in Basics | Tagged , | Comments closed

Ruby on Rails: Web Development on Mac OS X

pgadmin.jpg

Ruby on Rails with its noteworthy benefits and real-world applications in production made its web application framework a top choice. And it is not a shocker for Rails to succeed on the abundance of Mac OS X. Ruby on Rails is an open source tool that quickly generates great web applications backed up by SQL databases to keep up with the speed of the web. Members of the Rails core development team work with Mac. A prominent text editor used by Rails programmers is a Cocoa application called TextMate. That is why it is not much of a revelation that Mac OS X has been a preferential application for Rails’ expansion and development.

Posted in Basics | Tagged , | Comments closed

Rails web server

starting_rails1.jpg

If Mongrel and lighttpd are not installed, by default Rails will use WEBrick, the webserver that ships with Ruby. All these will guarantee you to always get up and run promptly. Rails will check first if Mongrel exists when you run script/server, then check on lighttpd and would finally fall back to WEBrick which is a small Ruby web server appropriate for development but not for production. Mongrel is a Ruby-based webserver possessing a C component that requires compilation. It is suitable for development and operation of Rails application. Lighttpd is considerably faster than MOngerl and WEBrick but entails additional installation and presently only works well on OS X/Unix.

Posted in Basics, Programming | Tagged , , , | Comments closed

Ruby Central

top_diamond.jpg

Ruby Central Inc. is a non-profit organization based in the United States that is committed to support and for the advocacy and promotion of the Ruby programming language. This organization was founded and established by a group of Ruby advocates like David Alan Black, Richard Kilmer and Chad Fowler. Ruby central is the parent of the annual International Ruby and Ruby on Rails Conferences that serves as a presence and contact point of corporate sponsors concerned in supporting and promotion theses conferences and other Ruby activities. Its first project was RubyConf 2002 and ever since, RubyConf’s have been held. Teaming up with the San Francisco-based Software Development Forum to produce the 2006 Silicon Valley Ruby Conference, Ruby central has also become a center for support of Ruby activities.

Posted in Basics | Tagged | Comments closed

Ruby and Merb get together and form Rails 3

Ruby on Rails is set to merge with its main competitor, Merb and end up becoming Rails 3:

We all realized that working together for a common good would be much more productive than duplicating things on each side of the fence. Merb and Rails already share so much in terms of design and sensibility that joining forces seemed like the obvious way to go. All we needed was to sit down for a chat and hash it out, so we did just that.

What this will mean in practice is that the Merb team is putting their efforts into bringing all of the key Merb ideas into Rails 3. Yehuda Katz will outright join the Rails core team, Matt Aimonetti will work on a new evangelism team, and Carl Lerche and Daniel Neighman (hassox) will be co-starring the effort to bring all this over. We’ve immortalized the merge with plaque page at rubyonrails.org/merb.

Always give peace a chance, I say.

Source

Posted in Information | Comments closed

Connection Pooling

Image Source: javaworld.com

Database connection pooling is already supported by Ruby on Rails 2.2! Basically, connection pooling occurs when several of the database connections are kept open and they are all ready for queries. And when Rails gets an HTTP request and queries the database, what it does is, it gets an open database connection from the several connections that are currently open. it then goes on with its query. After it has made its query, it automatically returns the connection to the pool. The connection pooling enables the user to have a better control over interaction in the database. And it boosts performance because Rails does not connect to the database every request. Without this feature, the surging search requests in the database can slow down the over all connection.

Posted in Basics | Comments closed

File Uploading using Rails


Image Source: images.devshed.com

If you want your site visitor to upload a certain file on your server, Rails make it an easy task to undertake the requirement. We will use the new application of Ruby on Rails called upload. We can create the basic structure of the application. And we will need simple Rails commands. Start off with C:\ruby>rails upload, then decide if you’re going to save the uploaded file. Create the directory and then check permissions. Next thing to do is to create the controller and models. You can call helper function content_type to know media type of the uploaded file. Next is to open a file in write mode so we will be using open helper function which is provided by File object. The render function is to be used to redirect to view files and to display message. The last is to create a view file uploadfile.rhtml. Set the parameter to True so that the action will pass on the data properly.

Posted in Basics | Comments closed

A Complete Cross-Platform Application


Image Source:oreillynet.com

Ruby on Rails is a complete cross-platform application for web development. It is the best architecture for developing application programming. Ruby on Rails has several advantages over other frameworks. They are what makes Ruby development tasks fast and easy. It provides a meta programming method for the creation of databased web applications, which is known as, Scaffold. Using this you can easily construct templates and models needed for the majority of the basic websites, homepages and even web portals. “WEBrick” is a new technology which Ruby development uses too. The over-all sense of this, is that the library, included in the Ruby distribution, provides basic HTTP web server services and tools. Prototype, is another technological advancement which is part of the distribution also.

Posted in Programming | Tagged | Comments closed

Several Command-Line Options


Image Source: www.anylinuxwork.com

Here are some few command line options in which can guide you in programming your Ruby on Rails:

-0[octal}
The number “0” flag specifies the record separator character (\0, if no digit follows). -00 indicates paragraph mode: records are separated by two successive default record separator characters. -0777 reads the entire file at once (as it is an illegal character). Sets $/.

-a
‘Auto split mode when used with -n or -p; equivalent to executing {$F at the top of each loop iteration.

-C directory
Changes working directory to directory before executing.

-c
Checks syntax only; does not execute the program.
–copyright
Prints the copyright notice and exits.

-d, –debug
Sets $DEBUG to true. This can be used by your programs to enable additional tracing.

-e ‘command’
Executes command as one line of Ruby source. Several -e’s are allowed, and the commands are treated as multiple lines in the same program. If programfile is omitted when -e is present, execution stops after the -e commands have been run.

Posted in Advanced, Basics, Information, Medium, Programming, Sample Code, Set-Up | Comments closed