Archive for the 'Set-Up' Category
Comments (Part 1)
Their use seems elementary but ask any well-seasoned programmer and they too use them. It allows you to understand complex functions or to explain the operation you’re going to do or just about what ever you would want to include in your programs as long as they are treated as comments. They also make great tools when troubleshooting/debugging programs for sometimes, the long days and nights do translate into a lot of code, some of which look almost all the same. Ruby reminds me of a documentation program we had included with previous programming languages such as C and even Cobol which has an add-on or function with the compiler which dissects the program and documents everything.
Comments are off for this postNext step : Creating the database for the filename application
The next phase or step would be to create a database for the application to use. Make sure the MySql engine is running and in the command window type “mysql -u root -p” and press enter and another enter for the password when prompted for there has not been any defined password yet. You are now logged into the engine as the root user and proceed to create the database by entering the following command “create database filename_development”. Also type in “grant all on filename_development.* to ‘ODBC’@'localhost’ this tells windows to grant access to a user named ODBC so you avoid an error when you try to access the said database from the command prompt. We next tackle the creation of tables that would allow the database to store the information we send it.
Comments are off for this postDatabase manipulation
The database has been initialized, so now we get down to business of defining the fields in that database and include a field that we would call a foreign key which allows the establishment of the one to many relationship between the tables. This part of the process requires quite a bit of background of database creation, manipulation and handling. It also requires knowledge regarding the workings of data types. So assuming you do not have much knowledge in such areas do some more reading to give you a better understanding of what how and why they are there. The ROR developers might say that it is very easy to do and use ROR but without the background on logic formulation, data types and manipulation as well as database handling the rest of the posts which would tackle ever hardening topics and operations would be very difficult to make sense of.
Don’t get me wrong, we just want to make life easier for you and not have you not understanding anything at all.
Comments are off for this postRoR Application Directories in-depth
There are quite a number of directories locate in the apps folder we have just created so to de-mystify them here are some explanations which hopefully would help you out. The directory “app/controllers” is where Rails searches for the controller classes which controls the web request from the user. The next one is the, “app/views” folder which houses the templates to which the data from the app is converted to HTML and then returned to the user’s browser. The next folder houses the “apps/models” subdirectory which contains the data classes that wraps the data stored within the application’s database (this is the messiest part of the framework in other frameworks). Then last of the vital sub-directories is the “app/helpers” which hold the helper classes of data that assists the view, model and controller classes keeping them small, organized and focused on the task it is supposed to do in the first place.
Comments are off for this postRuby on Rails Development Tips

Image Source: www.web2.socialcomputingmagazine.com
Ruby on Rails is great for acquiring ideas prototyped super quick. These tips will slow down growth and make apps less portable, but definitely progress the speed your system
Ruby on rails coding style:
• Try to evade the over indulgence use of helpers since it adds overhead.
• You may think about using memcached to cache your model and library computation results.
• Use a custom configuration file for passwords and API keys instead of keeping them in your Subversion repository. Use YAML and mirror the style of database.yml.
• Use constants when desired. Instead of repeating strings like the address of your customer service reply email, set it once in a constant (in environment.rb or the appropriate environment file) and use that throughout your application.
• Keep time in UTC. A no brainer, and easy to do.
• Don’t loop through ActiveRecord models inside other models. Use keen loading if you need to exertion with multiple associated models. Better yet, write a custom SQL query and let the database do the work for you.
Before You Start
Assuming you have even just a little background in programming with any language there are four basic programs and extensions that you need but are provided by the quick installers you’ve just downloaded to your hard drive. You have The Ruby programming language program files, the Rails part of the programming extension/platform, MySql or your database query handling system and the Apache which is a web server that you use to emulate your application’s execution on the web. Granting you have these set up properly and tested (instructions for which are included in the installer package). You can now start building your first application with RoR.
Comments are off for this postDocumenting Ruby
Documentation of a program is done by another program called the Parser which is the part of a program’s compiler that goes through a program line by line looking for all predefined characters allowing it to recognize calls to a pre-defined function in it’s library files (Similar to C’s LIB files where functions were pre-defined and called from) these pre-defined functions can be accessed by including the include file in the initialization phase of compilation where the parser recognizes the call, gets the definition of the function, uses it with the provided information and returns to the program for the next operation. This is more of the very fundamental workings of programming languages and how compilers understood the code which was written in a text editor. You will appreciate this later on when applications become more and more complex and debugging sends you tugging on your hair for hours on end to find the problem and fix it.
Comments are off for this postComments (Part 3)
The dos operations are still behind the scenes, they were just made friendlier say for getting the contents of a directory in dos, you used the “dir” command, in windows, and you did the same operation by simply clicking on a folder. Windows has the DIR command stored in code which is executed when a series of operations is done resulting in the folder opening. Ruby, though command line driven is a very powerful language for it takes the strengths of C improving it a lot with its own built in functions. Ruby treats everything as objects and yes even comments though they are not executed due to an exclusion flag of sorts.
Comments are off for this postComments (Part 2)
This is similar in Ruby for thousands of lines of code is very hard to describe manually so the RDOC. C is somewhat a sister language of Ruby and true to this many of its built-in functions are in C. If you have ever used C, you know the true power of the language. But C was initially more adept for mathematical operations rather than today’s visually based programming languages. This is still the case but the built in functions in the language allows shorter coding with the input only of required conditions or functions to make it work. Visual programming languages like Visual Basic and Visual FoxPro all use a GUI which can be compared to a system previously using DOS then having to install windows with its savvy GUI.
Comments are off for this postNext Step : Creating Empty Applications
Now that all has been set-up and is working, you should be able to create empty apps which is merely defining the application using rails which automatically creates all the necessary directories that are needed. Open a command prompt window and go to the directory where it was installed and proceed into the rails_apps directory. Type in ‘rails filename’ and rails creates all the necessary directories you would be needing for the development process. Don’t get freaked out when you see the multitude of directories for they will be filled out by “RAILS” and not by you manually. The next post will discuss some of the nuances of those dizzying directories to take some of the fog over them out.
Comments are off for this post








