Posts Tagged ‘Best Practices’

5

COMMENTS

Prevent registration of reserved login

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 [...]

GO
2

COMMENTS

Rails Best Practices 6: Filters and helpers file

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 [...]

GO
15

COMMENTS

Rails Best Practices 4: Put method in the right model

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 [...]

GO
14

COMMENTS

Rails Best Practices 3: Increase Controller’s readability

[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 [...]

GO
4

COMMENTS

Rails Best Practices 2: Move logic to model

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 [...]

GO

Copyright 2012 DevInterface s.n.c.

DevInterface Blog is proudly powered by WordPress