Skip to content

Instantly share code, notes, and snippets.

<?php
class AccessComponent extends Object {
public $settings = array();
public $defaults = array(
'admin_required' => array(),
'auth_denied' => array(),
'auth_required' => array(),
'denied' => array(),
'callback' => 'initialize');
class CreateContentelements < ActiveRecord::Migration
def self.up
create_table :contentelements do |t|
t.string :name
t.text :data
t.references :elementdefinition
t.timestamps
end
end
<%=
raw Liquid::Template.parse(
'<table>{% tablerow item in items cols: 2 %}
<td>{{ item.id }}</td>
<td>{{ item.created_at }}</td>
{% endtablerow %}
</table>
'
).render('items' => Element.find(:all).collect{|item| item.attributes})
%>
# have this
attribs = ['src', 'alt', 'title', 'longdesc']
# call this
raw Liquid::Template.parse(@element.template.data).render(
'src' => data['src'],
'alt' => data['alt'],
'title' => data['title'],
'longdesc' => data['longdesc'],
)
Element HasOneToMany Blocks
Block HasOne Element OR HasOne Data
Element AlwaysBelongsTo Definition
Definition HasZeroToMany Elements
Element AlwaysBelongsTo Transformation
Transformation HasZeroToMany Elements
http://thechangelog.com/post/1121940971/terminitor-automate-your-workflow
@ionas
ionas / rails bookmark
Created December 25, 2010 02:47
rails bookmark
http://railstrip.ourgreatjourney.com/how-to-paginate-sort-and-search-a-table-with-ajax-and-rails-jquery-style/
# index.js.erb:
$("#products").html(
"<%= escape_javascript(render('products')) %>"
);
$("#products_search_hidden_fields").html(
"<%= escape_javascript(render('products_search_hidden_fields')) %>"
);
# index.html.erb:
<%= form_tag products_path, :method => 'get', :id => "products_search" do %>
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(function() {
// Hide the form button
$('#products_search input[type="submit"]').hide();
// Push searches onto the location hash
var inputTimeoutId = -1;
@ionas
ionas / product.rb
Created December 27, 2010 18:49
Call via Product.labels(:price)
# TODO: do label translation here as well.
@@labels = {
:price => 'Price incl. VAT'
}
def self.labels(attribute_name)
if @@labels[attribute_name]
@@labels[attribute_name]
else
attribute_name.to_s.titleize
end