SlideShare uma empresa Scribd logo
1 de 25
Rails Best Practices From Feedback
Move finder to scope or method
Move finder to scope or method
Use model callback
Use model callback
Move Model Logic to Model
Move Model Logic to Model
Overuse route customizations
Overuse route customizations Using Namespace  Further , it can be applied to PermissionManagerController http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
Metaprogramming How about  all_cmts,all_hrs,all_employees  ….WOW!
Metaprogramming role.hr?  Role.all_cmts
Law of Demeter
Law of Demeter
Use virtual attributes How come that person doesn’t hold a ‘role’ attribute? What if we can do add one?
Use virtual attributes railscasts.com/episodes/16-virtual-attributes railscasts.com/episodes/167-more-on-virtual-attributes
Favor helper_method
Favor helper_method
Favor helper_method Maybe …..
Move View logic to Helper
Move View logic to Helper
Replace instance variable with local variable
Permission Check http://hobocentral.net/
Permission Check What’s more ..
Rails Best Practice Gem https://github.com/flyerhzm/rails_best_practices http://www.ihower.tw/
Thanks

Mais conteúdo relacionado

Semelhante a rails best pratice from feedback

JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Guillaume Laforge
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
ThoughtWorks
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
Jim Jones
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
webuploader
 
Learn java
Learn javaLearn java
Learn java
Palahuja
 

Semelhante a rails best pratice from feedback (20)

Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
Efficient Rails Test Driven Development (class 4) by Wolfram ArnoldEfficient Rails Test Driven Development (class 4) by Wolfram Arnold
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
 
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
 
Rails missing features
Rails missing featuresRails missing features
Rails missing features
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: Refactoring
 
What is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | EdurekaWhat is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | Edureka
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018
 
RoR 101: Session 3
RoR 101: Session 3RoR 101: Session 3
RoR 101: Session 3
 
Rest in Rails
Rest in RailsRest in Rails
Rest in Rails
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Learn java
Learn javaLearn java
Learn java
 
Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rs
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Search Engine Spiders
Search Engine SpidersSearch Engine Spiders
Search Engine Spiders
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 

rails best pratice from feedback

Notas do Editor

  1. So we can use built -in validation of reviewing model.like validatonpresenence and uniquecann't be the same guy for reviewee and reviewerCompare with code of last slide