Skip to content

Instantly share code, notes, and snippets.

@VictorTpo
Last active November 4, 2015 15:30
Show Gist options
  • Save VictorTpo/186c67515b74a29b3974 to your computer and use it in GitHub Desktop.
Save VictorTpo/186c67515b74a29b3974 to your computer and use it in GitHub Desktop.

Pour avoir du joli code, il faut partir de la vue et remonter.

EXEMPLE : "Qu'est-ce que je veux VOIR (et non avoir)"

Ben je afficher :

@ma_var.value

Et hop une belle vue !

Bon là ça va bugger donc go controller. Et là, once again "Qu'est-ce que je veux voir"

Je veux voir quelque chose comme :

@ma_var = Themodel.new('foo').just_do_it

Et hop un beau controller !

Et pour finir le model :

class Themodel
  def intialize(label)
    @data = OtherModel.find(label).do_something
  end
  
  def just_do_it
    @data.some_field
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment