Hi,
The recent RailsEnvy Podcast
http://railsenvy.com/2009/11/09/episode-099
has introduced some presentations in different RailsConf. And they
mentioned a presentation "Rails Best Practices" from Kungfu RailsConf
in Shanghai China. I attended this RailsConf and very like the
presentation, too.
What I am doing these days is writing a gem to automatically check
rails app files according to the Rails Best Practices on that
presentation.
The repository of the gem is:
http://github.com/flyerhzm/rails_best_practices
It is a code static parser tool, just like roodi, flay and flog. It is
very easy to use. Just go to the root directory of your rails app and
type
rails_best_practices .
notice the period at the end, it can be the relative or absolute path
of your rails app.
Please allow me paste the outputs for parsing insoshi project
Macintosh:insoshi richard$ rails_best_practices .
./app/models/message.rb:164 - use observer
./app/models/comment.rb:87 - use observer
./app/models/email_verification.rb:26 - use observer
./config/routes.rb:96 - not use default route
./config/routes.rb:97 - not use default route
./db/migrate/005_create_forums.rb:16 - isolate seed data
./db/migrate/013_add_admin.rb:20 - isolate seed data
./db/migrate/013_add_admin.rb:21 - isolate seed data
./db/migrate/023_add_email_verified.rb:13 - isolate seed data
./db/migrate/20081014231622_move_thumbnails.rb:16 - isolate seed data
./db/migrate/20081014231622_move_thumbnails.rb:30 - isolate seed data
./db/migrate/20081015002258_migrate_photo_data.rb:11 - isolate seed
data
./db/migrate/20081015002258_migrate_photo_data.rb:17 - isolate seed
data
./db/migrate/20081015002258_migrate_photo_data.rb:28 - isolate seed
data
./app/controllers/messages_controller.rb:60 - move model logic into
model (@message called_count > 4)
./app/controllers/people_controller.rb:18 - move model logic into
model (@person called_count > 4)
./app/controllers/people_controller.rb:50 - move model logic into
model (@person called_count > 4)
./app/controllers/sessions_controller.rb:22 - move model logic into
model (@person called_count > 4)
./db/migrate/001_create_people.rb:2 - always add db index (comments =>
commentable_id)
./db/migrate/001_create_people.rb:2 - always add db index
(email_verifications => person_id)
./db/migrate/001_create_people.rb:2 - always add db index (topics =>
person_id)
./db/migrate/001_create_people.rb:2 - always add db index (galleries
=> person_id, galleries => primary_photo_id)
./db/migrate/001_create_people.rb:2 - always add db index (events =>
person_id, events => person_id, events => event_id, events =>
person_id)
./db/migrate/001_create_people.rb:2 - always add db index (page_views
=> user_id)
./db/migrate/001_create_people.rb:2 - always add db index
(event_attendees => person_id, event_attendees => event_id)
./db/migrate/001_create_people.rb:2 - always add db index (posts =>
person_id)
./db/migrate/001_create_people.rb:2 - always add db index (connections
=> person_id, connections => contact_id)
./db/migrate/001_create_people.rb:2 - always add db index (thumbnails
=> parent_id)
./app/controllers/connections_controller.rb:83 - move finder to
named_scope
./app/controllers/sessions_controller.rb:22 - replace complex creation
with factory method (@person attribute_assignment_count > 2)
./app/controllers/admin/forums_controller.rb:1 - use filter for @forum
= Forum.find(params[:id]) in show,edit,update,destroy
./app/controllers/comments_controller.rb:3 - use filter for redirect_to
(comments_url) in index,show
./app/controllers/events_controller.rb:1 - use filter for
@month_events = Event.monthly_events(@date).person_events
(current_person) in index,show
./app/controllers/galleries_controller.rb:1 - use filter for @body =
"galleries" in show,index
./app/controllers/galleries_controller.rb:1 - use filter for @gallery
= Gallery.find(params[:id]) in edit,update,correct_user_required
./app/controllers/messages_controller.rb:1 - use filter for @message =
Message.find(params[:id]) in destroy,undestroy,authenticate_person
./app/controllers/people_controller.rb:1 - use filter for @person =
Person.find(params[:id]) in show,edit,update,common_contacts
./app/controllers/photos_controller.rb:1 - use filter for @photo =
Photo.find(params[:id]) in
show,update,set_primary,set_avatar,correct_user_required
./app/controllers/sessions_controller.rb:2 - use filter for @body =
"login single-col" in new,failed_login
./app/controllers/topics_controller.rb:1 - use filter for @topic =
Topic.find(params[:id]) in show,edit,update,destroy
Found 40 errors.
Are you interested in this gem? Any suggestions are welcome.
Thanks,
Richard Huang