I <3 Ruby on Rails
Ruby On Rails
Ruby on Rails is an application framework, written in Ruby and whose mainly purpose is to help ease the workflow of an MVC oriented website.
MVC = Model - View - Controller
This is the base of RoR (Ruby on Rails), and pretty much the main reason to use it (instead of other frameworks.)
A Model is anything that holds values, you could think of them as 'objects'. Although that is not quite accurate as models can also be a relation between two other Models. They are often represented by one column in the database. ( Although 'virtual' models exist as well. )
Here is an example:
A Forum User has a Name, Password, Settings, Posts, Signature, Avatar.
So it's model would be something like this in Rails:
attr_accessible is a security feature with which you can specify which attribute can be 'mass-assigned'. That means you update them all at once instead of having them individually. ( Mostly for convenience as it saves you from typing a lot. )
the lines 'has_one' and 'has_many' do exactly what it says, it tells rails that there is a setting that belongs to this User. There are also many posts that belong to this User.
A Controller is the application logic, it is what allows you to specify what an user is allowed to do. What he can see, etc...
For example let's consider a Forum Model, it has many Threads.
Here is an example of a Threads controller:
params is a hash where you have the parameters of the page.
With http://example.com/threads/1 the params hash would hold as an ":id" variable the number 1 which is the id of the thread model.
It all reads pretty much like English so it should be straightforward.
A View is what is displayed to the user. In it you can use Ruby ( by default it uses ERB as it's templating system ) to change the appearance of what you want.
Here is an example of my upcoming website:
This is the Roleplay Creation page. As you can see I use HTML & Ruby interleaved.
So this is why I love Ruby on Rails, if you want to do a resource oriented website it just fits the job perfectly. It's 'magic' is always the right way, especially if you are beginning.
I highly suggest this Framework to anyone starting into Web Development as it only beneficial. You learn a lot simply by shaping your application the 'rails way'.
Stay tuned for more!
If you wish to dive into Rails I highly suggest this tutorial:
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
It covers anything you need to know to start out.
-
2
3 Comments
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Join the herd!Sign in
Already have an account? Sign in here.
Sign In Now