Rubyr

Ask me anything   About Ruby on Rails, iPhone and Android development.

Alternativa para validates_uniqueness_of

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 more
— 7 months ago
Ruby: rake aborted! uninitialized constant Rake::DSL

Estava 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’

— 7 months ago
Ruby and Regular expressions (regex)

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.

Read more
— 7 months ago
Git: Usando Git com servidores compartilhados

GitHub is awesome, really awesome for open source projects and for projects with multiple people. In fact, if you use your own git setup for an open source project, you are most likely hindering your project’s progress and wasting your time.

Read more
— 7 months ago
Git: Ignore files

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.

Read more
— 7 months ago
Git: Ignorando arquivos e pastas

 

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.

Read more
— 7 months ago
Utilizando o Plugin Prawnto

The prawnto plugin gives all controllers access to the prawnto method that controls the prawnto/prawn options. 

Read more
— 7 months ago with 3 notes
#ruby on rails  #plugin 
Gerando PDFs com Rails e Prawn

It’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
— 7 months ago