Skip to content

Instantly share code, notes, and snippets.

View piclez's full-sized avatar

Peter WD piclez

View GitHub Profile
We couldn’t find that file to show.
#!/usr/bin/env ruby -w
# This should be run through './script/runner'
options = YAML.load($stdin.read)
demo = Demo.find(options[:demo])
runner = Outback::Runner.new
runner.manager = demo.manager
throw :halt, Proc.new { |controller|
@user = params[:login]
render(:index_not_logged_in)
} if !current_user
MODEL:
class Gallery
include DataMapper::Resource
belongs_to :user
has n, :photos
def thumbnail
"1"
end
Merb::Router.prepare do |r|
#Merbauth routes is broken (capture is depricated)
slice(:MerbAuth, :path => "", :default_routes => false)
# This is the default route for /:controller/:action/:id
# This is fine for most cases. If you're heavily using resource-based
# routes, you may want to comment/remove this line to prevent
# clients from calling your create or destroy actions with a GET
default_routes
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
/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 Contacts < Application
# provides :xml, :yaml, :js
def index
@contacts = Contact.all
display @contacts
end
def show
@contact = Contact.get(params[:id])
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
<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);