Skip to content

Instantly share code, notes, and snippets.

View piclez's full-sized avatar

Peter WD piclez

View GitHub Profile
class Segment
include DataMapper::Resource
property :id, Serial
property :title, String
has n, :products, :through => Resource
end
class Product
include DataMapper::Resource
property :id, Integer, :serial => true
# lib/color_logger.rb
module Merb
class Logger
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # 30 = black 31 = red 32 = green 33 = yellow blue 34 = 35 = magenta 36 = cyan 37 = white
Colors = Mash.new({
:fatal => 31,
:error => 31,
:warn => 33,
:info => 38,
module Admin
class Items < Application
# provides :xml, :yaml, :js
def index
@items = Item.all
display @items
end
def show(id)
r.namespace :admin do |admin|
admin.resources :products
r.resources :product_lines do |product_line|
product_line.resources :products
end
end
upstream localhost {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name localhost;
# Set the max size for file uploads to 50Mb
client_max_body_size 80M;
<div id="update"></div>
<a href="/test" id="test" rel="#update">test</a>
<script type="text/javascript">
$(document).ready(function(){
$("#test").click(function(){
event.preventDefault();
$(this.rel).load(this.href);
class Asset
include DataMapper::Resource
property :id, Integer, :serial => true
property :user_id, Integer, :nullable => false, :index => true
property :title, String
property :filename, String
property :content_type, String
property :size, Integer
property :created_at, DateTime
class Contacts < Application
# provides :xml, :yaml, :js
def index
@contacts = Contact.all
display @contacts
end
def show
@contact = Contact.get(params[:id])
/users/:id
/^/users(/|/index)?(\.:format)?$/
/^/users/new$/
/^/users/:id(\.:format)?$/
/^/users/:id/edit$/
/^/users/:id/delete$/
/^/users/?(\.:format)?$/
/^/users/:id(\.:format)?$/
/^/users/:id(\.:format)?$/
class Galleries < Application
before :login_required, :exclude => [:index, :show]
def index
# DM associations bug?
@galleries = User.first(:login => params[:login]).galleries
#@galleries = Gallery.all
display @galleries
end