Alternativa para quem abusa de validates_uniqueness_of.
Deve possibilitar o ActiveRecord a identificar erros de violação “unique constraint” da base de dados. Por exemplo, podemos fazer o mesmo trabalho do validates_uniqueness_of:
Read moreEstava tentando rodar o comando $ rake db:migrate e o seguinte erro aparecia:
rake aborted!
uninitialized constant Rake::DSL
Resolvi apenas adicionando no Rakefile do projeto o seguinte,
logo após a linha require ‘rake’:
require ‘rake/dsl_definition’
Regular expressions, though cryptic, is a powerful tool for working with text. Ruby has this feature built-in. It’s used for pattern-matching and text processing.
From time to time there are files you don’t want git to track. There are a few methods of telling git what files to ignore.
Nós não precisamos que o GIT monitore tudo em nossos projetos, sejam arquivos compilados, arquivos com senhas, ou arquivos temporários que os editores adoram criar. Normalmente, manter coisas fora de seu VCS é uma tarefa difícil de gerenciar e chata de configurar. Com GIT não! Usando o arquivo .gitignore e algumas outras opções, vamos aprender a ignorar arquivos por projeto e por usuário.
The prawnto plugin gives all controllers access to the prawnto method that controls the prawnto/prawn options.
Read moreIt’s been a while since I’ve needed to generate a PDF in ruby. I typically discourage clients from it because, well, I’m lazy and it’s a pain. I’ve always kind of hated pdf generation. It has always felt a tad awkward, be it in PHP, ColdFusion (6, unfortunately before cfdocument) and even Ruby. This time around, I decided to try out the new kid on the block, Prawn. On the website I just linked to, they recommend the prawnto plugin, so I gave it a whirl. My conclusions are that they work pretty well. Granted, I was just creating some text and formatting it, but I got up and running quickly. For your enjoyment, I’ll cover some basics below.
Read more