Every time you create a web application where users can register, it is good to exclude some login or username so that they can not be used.
A classic example is the login “admin”.
I believe that no one wishes that in its application will be a registered user with the username “admin” then can contact [...]
Tags: Best Practices, login reservation, rails, ruby, ruby on rails, validation
Posted in Development, Ruby |
With the today’s post I shall conclude my series on Ruby On Rails Best Practices . This is not because the required topics are completed, but rather because after the release of Rails 3.0, some constructs have been changed and should be reviewed.
Probably in future we will return to talk about best practices, but [...]
Tags: after_filter, before_filter, Best Practices, helpers, rails, ruby on rails
Posted in Development, Metodologies, Ruby |
In today’s post I will show some optimization we can do for models. I’ll focus on how to put methods inside the right model and delegation to get a better code.
1. Put method in the right model
In our example, suppose we want to represent the animal world by creating a model Kind that represents [...]
Tags: Best Practices, delegate, named_scope, ruby on rails
Posted in Development, Ruby |
[POST UPDATE ON 19/07/2010 - 15:45]
Continuing our analysis of the Rails Best Practices today we’ll see two other tricks to make more readable method of the controller.
1. Methods within model
Suppose we have the classic user registry defined in such a way that an admin user can enable or disable other users.
The deactivate method inside user [...]
Tags: Best Practices, controller, factory method, ruby on rails
Posted in Development, Metodologies, Ruby |
Today we continue our analysis of the Rails Best Practices.
In the previous post we saw Named Scope, Model Association and
Following the same direction, in today’s post we’ll examine the use of Callback Model and Virtual Attribute.
1. Virtual Attribute
Suppose we have a customers list table defined as follows
123456create_table "clients", :force => true do |t|
t.string [...]
Tags: Best Practices, model callback, ruby on rails, virtual attributes
Posted in Development, Metodologies, Ruby |
COMMENTS