Bad practices in Ruby on Rails -
i'm looking examples of bad practices in ruby on rails, presentation on not do.
my biggest on use update_attribute on model after_save hook.
object.update_attribute(:only_one_field, "some value")
as open ended question, wait week or 2 , select answer voted answer.
have fun!
too mass-assignment without using
attr_protected
use of many plugins - there many gems , rails has sooo many plugins available use in applications. however, when use gem or plugin, understand how code operating (unless @ source, people never do). huge problem. don't know how debug code properly, plugins , gems clash 1 another, security becomes major concern, etc. reason, recommend writing all own code. sure, devise nice authentication, can tell me how works , queries run? have control on optimization? (i'm not picking on devise, showing clear example many ror developers familiar with)/
keeping unwanted pages/actions - many rails developers use scaffolding (because nice), don't bother remove unwanted actions. simple adding
:only => []
or:except => []
in routes file, people never do! don't know how many rails sites have been hacked or damaged because people didn't restrictdelete
actiontrying go against ruby - developers come language have difficulties "ruby-way." 1 of notable examples having non-incrementing or non-integer primary keys.
too controller, not enough model - rails had "fat model, skinny controller" principle many developers break.
violations of mvc - accessing
params
in models, trying hack things controllers, etc.not changing default rails unique session token (which not random)
writing sloppy code - ruby has great way of making code readable. if come java or php or python, code plain ugly until learn ruby
saying rails "is language" or "i code in rails" - absolutely, positively jerks me wrong way when hear "i code in rails" or "rails favorite language", etc. rails not language. rails framework built on ruby. isn't related security or like, you'll irritate lot of ruby developers if start saying rails language. it's framework.
comparing php , rails - don't it. again, php language, rails framework. comparing them unfair. (you can compare ruby , php or rails , codeignitor or cakephp, etc)
not catching errors - if can go wrong, someone, assume will, , plan ahead
failing optimize queries - absolutely kills me. rails doesn't force know sql php did (before orm's doctrine), rails apps tend slllloooowww unless developer actually aware can optimize query (joins what??)
using many generators - should able create class (controller, model, test, view) without use of generator.
using rails large-scale system - yeah, of aren't going this, ask twitter , github happens if build front , backend in rails... let's twitter uses custom java backend now...
have freaking clue - annoyed because people don't know how
has_many
relationship works (just 1 of 21914232 examples of dumb rails developers)!not commenting code
relying on rails instead of sql or dom (javascript/html) perform functions
Comments
Post a Comment