Skip to content

Instantly share code, notes, and snippets.

View edison's full-sized avatar
🏠
Working from home

Edison Machado edison

🏠
Working from home
View GitHub Profile
@edison
edison / destroy.rb
Created September 8, 2012 19:28
destroy
class QuotesController < ApplicationController
def home
@quote = Quote.all.sort_by{rand}.slice(0,10).first
respond_to :html
end
def show
@quote = Quote.find params[:id]
respond_to :html
end
@edison
edison / link.erb
Created September 8, 2012 19:30
link
@edison
edison / form.erb
Created September 8, 2012 19:46
form
<% if @quote.errors.any? %>
<div class="alert alert-error">
<% @quote.errors.full_messages.each do |msg| %>
<p><%= msg %></p>
<% end %>
</div>
<% end %>
<%= form_for @quote do |f| %>
<%= f.label :content %>
@edison
edison / controller.rb
Created September 8, 2012 19:53
controller
class QuotesController < ApplicationController
def index
@quotes = Quote.all
respond_to :html
end
def home
@quote = Quote.all.sort_by{rand}.slice(0,10).first
respond_to :html
end
@edison
edison / _quote.erb
Created September 8, 2012 19:54
_quote
<div class="hero-unit">
<% if @quote %>
<blockquote>
<p><%= @quote.content %></p>
<small><%= @quote.author %></small>
</blockquote>
<% else %>
<p>Nenhuma frase cadastrada.</p>
<% end %>
</div>
@edison
edison / index.erb
Created September 8, 2012 19:55
index
<% if @quotes.any? %>
<table class="table table-striped">
<tbody>
<% @quotes.each do |quote| %>
<tr>
<td><%= quote.content %></td>
<td><%= link_to 'Excluir', quote_path(quote), method: :delete, confirm: 'Tem certeza?', class: 'btn' %></td>
</tr>
<% end %>
</tbody>
@edison
edison / pt.yml
Created September 8, 2012 20:04
locale
pt:
activerecord:
attributes:
quote:
content: Frase
author: Autor
@edison
edison / errors.yml
Created September 8, 2012 20:13
errors
pt:
activerecord:
attributes:
quote:
content: Frase
author: Autor
errors:
models:
quote:
@edison
edison / localizacao.md
Created September 8, 2012 20:23
localicazao

Estrutura do arquivo .yml de localizacao:

  pt:
    produtos:
      cadastro:
        salvar: Salvar produto

Utilizando o helper t para traduzir nas views:

#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid