Related Link

Generating a controller

Posted in Ruby on Rails, Web Design

Now that we have our model in place (refer to previous article: Generating a model on Ruby), let’s build a controller. In the same way that we generated a model, we generate a controller by running the script/generate script from our application’s root folder.

Run the generate script from the command line again, but this time, pass controller as the first parameter:
$ ruby script/generate controller


Read the rest of this entry »

Generating a model in Ruby

Posted in Ruby on Rails, Web Design

In previous articles we had discussed and introduced the principles behind the model-view-controller architectural pattern, and saw how each of the components is implemented within the Rails framework. Now lets use those knowledge on Rails’s code generation techniques to create components.

generate can be called from the command line and takes several parameters. The first parameter is the type of component that’s to be generated. You can probably guess which value I’m going to suggest you use for this parameter. We’re creating a model, so the parameter to pass is simply model. Let’s take a look at what happens when we pass that to the script: Read the rest of this entry »

Testing and Debugging

Posted in Ruby on Rails

Testing is a number of different types of testing are supported by Rails, including automated and integration testing. The concept of automated testing isn’t new to the world traditional software development, but it’s fairly uncommon in web application development. While most Java-based web applications make use of comprehensive testing facilities,
a large number of PHP and Perl web applications go live after only some manual tests have been performed (and sometimes without any testing at all!). Although performing automated tests may be an option, developers may decide not to use them for reasons ranging from the complexity of the task to time constraints.

The generate command that we introduced a moment ago can automatically create testing templates that you can use with your controllers, views, and models.
Read the rest of this entry »

ActionPack Module

Posted in Ruby on Rails

ActionPack is the name of the library that contains the view and controller parts of the MVC architecture. Unlike the ActiveRecord module, these modules are a little more intuitively named: ActionController and ActionView. Exploring application logic and presentation logic on the command line doesn’t make a whole lot of sense (views and controllers are designed to interact with a web browser).

ActionController (the Controller)
The controller handles the application logic of your program, acting as a glue between the application’s data, the presentation layer, and the web browser. In this role, a controller performs a number of tasks, including: Read the rest of this entry »

Defining Relationships Between Objects

Posted in Ruby on Rails

As well as the basic functionality that we’ve just seen, ActiveRecord makes the process of defining relationships (or associations) between objects as easy as possible. Of course, it’s possible with some database servers to define such relationships entirely within the database schema. However, in order to put ActiveRecord through its paces, let’s look at the way it defines these relationships within Rails.

Object relationships can be defined in a variety of ways; the main difference between these relationships is the number of records that are specified in the relationship.
The primary types of database associations are: Read the rest of this entry »

Favorite Link