Skip to content

Instantly share code, notes, and snippets.

View fernandomm's full-sized avatar

Fernando Morgenstern fernandomm

View GitHub Profile
def show
@post = current_user.posts.find_by_id params[:id]
unless @post
redirect_to posts_path, :alert => 'Post not found'
end
end
If for some reason you cannot inherit from InheritedResources::Base, you can call inherit_resources in your controller class scope:
class AccountsController < AnotherController
inherit_resources
end
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>*****</title>
<link href="/assets/application.css" media="all" rel="stylesheet" type="text/css">
<script src="/assets/application.js" type="text/javascript"></script>
</head>
<body>
config.actions do
# root actions
dashboard # mandatory
# collection actions
index # mandatory
new
export
bulk_delete
# member actions
show
@fernandomm
fernandomm / rails_admin.pt-BR.yml
Created February 21, 2012 14:38 — forked from krsmurata/rails_admin.pt-BR.yml
Portuguese (pt-BR) translation for RailsAdmin 3.2
pt-BR:
home:
name: Home
views:
pagination:
previous: "&laquo; Anterior"
next: "Próximo &raquo;"
truncate: "…"
admin:
misc:
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'twitter-bootstrap-rails', '2.0'
gem 'spec'
@fernandomm
fernandomm / gist:1680654
Created January 26, 2012 02:50
Zend Form decorators for Twitter Bootstrap
<?php
$form = new Zend_Form();
// Add your elements here
$form->removeDecorator('HtmlTag');
$elementNames = array();
foreach ($form->getElements() as $element) {
#!/usr/bin/php
<?php
if (!isset($argv[1])) {
exit('Please, choose a number.'. PHP_EOL);
}
$numero = (int) $argv[1];
if ($numero < 3 || $numero > 1000) {
exit('Number should be between 3 and 1000.'. PHP_EOL);
@fernandomm
fernandomm / gist:1560794
Created January 4, 2012 16:26
Update clientOnly dataSource.
if ( unique_clickers_form.getValue('unique') == false ) {
data = unique_clickers_form.getValue('filtered');
} else {
data = unique_clickers_form.getValue('unfiltered');
}
clickers_grid.dataSource.testData = data;
clickers_grid.invalidateCache();
criteria = clickers_grid.getCriteria();
clickers_grid.setData(data);
clickers_grid.dataArrived();
clickers_grid.setCriteria(criteria);