Estrutura do arquivo .yml de localizacao:
pt:
produtos:
cadastro:
salvar: Salvar produto
Utilizando o helper t
para traduzir nas views:
def bubble_sort(array) | |
n = array.length | |
swapped = true | |
while swapped do | |
swapped = false | |
(n - 1).times do |i| | |
if array[i] > array[i + 1] | |
array[i], array[i + 1] = array[i + 1], array[i] |
class Website::SessionsController < ::Devise::SessionsController | |
respond_to :js | |
layout false | |
# POST /resource/sign_in | |
def create | |
self.resource = warden.authenticate(auth_options) | |
if resource && resource.active_for_authentication? | |
sign_in(resource_name, resource) |
# Amount should be a decimal between 0 and 1. Lower means darker | |
def darken_color(hex_color, amount=0.4) | |
hex_color = hex_color.gsub('#','') | |
rgb = hex_color.scan(/../).map {|color| color.hex} | |
rgb[0] = (rgb[0].to_i * amount).round | |
rgb[1] = (rgb[1].to_i * amount).round | |
rgb[2] = (rgb[2].to_i * amount).round | |
"#%02x%02x%02x" % rgb | |
end | |
#!/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 |
Estrutura do arquivo .yml de localizacao:
pt:
produtos:
cadastro:
salvar: Salvar produto
Utilizando o helper t
para traduzir nas views:
pt: | |
activerecord: | |
attributes: | |
quote: | |
content: Frase | |
author: Autor | |
errors: | |
models: | |
quote: |
pt: | |
activerecord: | |
attributes: | |
quote: | |
content: Frase | |
author: Autor |
<% 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> |
<div class="hero-unit"> | |
<% if @quote %> | |
<blockquote> | |
<p><%= @quote.content %></p> | |
<small><%= @quote.author %></small> | |
</blockquote> | |
<% else %> | |
<p>Nenhuma frase cadastrada.</p> | |
<% end %> | |
</div> |
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 |