Created
October 29, 2011 02:08
-
-
Save ethnt/1323998 to your computer and use it in GitHub Desktop.
Trying to get Joint to work with Padrino.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Admin.controllers :backgrounds do | |
before do | |
authenticated? | |
end | |
get :index do | |
@backgrounds = Background.all | |
render 'backgrounds/index' | |
end | |
post :upload do | |
background = Background.create(params[:background]) | |
if background.save | |
flash[:notice] = "Your background has been uploaded." | |
redirect url(:backgrounds, :index) | |
else | |
flash[:error] = "Something went wrong and your background was not uploaded." | |
redirect url(:backgrounds, :index) | |
end | |
end | |
post :activate do | |
Background.set({:active => true}, :active => false) | |
background = Background.find(params[:id]) | |
background.active = true | |
if background.save | |
flash[:notice] = "The background has been created." | |
redirect url(:backgrounds, :index) | |
else | |
flash[:error] = "The background has not been created." | |
redirect url(:backgrounds, :index) | |
end | |
end | |
delete :destroy do | |
background = Background.find(params[:id]) | |
if background.destroy | |
flash[:notice] = "The background hath been destroyed." | |
redirect url(:backgrounds, :index) | |
else | |
flash[:error] = "Something went wrong and the background hath not been destroyed." | |
redirect url(:backgrounds, :index) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#inner.row | |
= partial 'partials/navigation' | |
%section#body | |
%h2 | |
backgrounds | |
=flash_tag :notice | |
- if !@backgrounds.blank? | |
%table | |
%thead | |
%tr | |
%th Name | |
%th Link to Media | |
%th Actions | |
%tbody | |
- @backgrounds.each do |background| | |
%tr{:class => background.active} | |
%td= background.name | |
%td= background.media | |
%td | |
%form.inline{:action => url(:backgrounds, :activate), :method => "post"} | |
%input{:name => "id", :type => "hidden", :value => background.id}/ | |
- if !background.active | |
%button.inline{:type => "submit", :value => "Activate"} Activate | |
— | |
%form.inline{:action => url(:backgrounds, :destroy), :method => "post"} | |
%input{:name => "id", :type => "hidden", :value => background.id}/ | |
%input{:name => "_method", :type => "hidden", :value => "delete"}/ | |
%button.inline{:type => "submit", :value => "Delete"} Delete | |
- else | |
%p | |
No backgrounds! | |
%section.meta.row | |
%form{:action => url(:backgrounds, :upload), :method => "post", :enctype => "multipart/form-data"} | |
%p | |
%input{:name => "background[name]", :placeholder => "Name", :type => "text"}/ | |
%p | |
%input{:name => "background[file]", :type => "file"}/ | |
%p | |
%button.green{:type => "submit"} Create |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Background | |
include MongoMapper::Document | |
plugin Joint | |
key :name, String | |
key :active, Boolean | |
attachment :file | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"name"=>"Sea Green", "file"=>{:filename=>"sea-green.jpg", :type=>"image/jpeg", :name=>"background[file]", :tempfile=>#<File:/tmp/RackMultipart20111028-27504-ly71fs>, :head=>"Content-Disposition: form-data; name=\"background[file]\"; filename=\"sea-green.jpg\"\r\nContent-Type: image/jpeg\r\n"}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> Padrino/0.10.0 has taken the stage development at http://0.0.0.0:4242 | |
>> Thin web server (v1.2.11 codename Bat-Shit Crazy) | |
>> Maximum connections set to 1024 | |
>> Listening on 0.0.0.0:4242, CTRL+C to stop | |
DEBUG - [29/Oct/2011 14:40:37] "Resolving layout /var/www/fhsclock/admin/views/layouts/application" | |
DEBUG - [29/Oct/2011 14:40:37] "GET (0.5119ms) 127.0.0.1 - - /admin/backgrounds HTTP/1.1 - 200 3693" | |
NoMethodError - undefined method `path' for #<Hash:0xafb66c0>: | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/joint-0.6.0/lib/joint.rb:18:in `name' | |
(eval):15:in `file=' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/keys.rb:187:in `block in attributes=' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/keys.rb:185:in `each_pair' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/keys.rb:185:in `attributes=' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/keys.rb:215:in `assign' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/accessible.rb:19:in `assign' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/protected.rb:28:in `assign' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/keys.rb:168:in `initialize' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/dirty.rb:12:in `initialize' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/sci.rb:32:in `initialize' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:112:in `new' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:112:in `block in initialize_each' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:111:in `each' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:111:in `initialize_each' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/mongo_mapper-0.9.2/lib/mongo_mapper/plugins/querying.rb:30:in `create' | |
/var/www/fhsclock/admin/controllers/backgrounds.rb:13:in `block (2 levels) in <top (required)>' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:486:in `block in route' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:736:in `instance_eval' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:736:in `route_eval' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block (2 levels) in process_destination_path' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `catch' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:49:in `block in process_destination_path' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `instance_eval' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:22:in `process_destination_path' | |
(eval):16:in `block (2 levels) in inject_root_methods' | |
(eval):6:in `catch' | |
(eval):6:in `block in inject_root_methods' | |
(eval):49:in `block in inject_root_methods' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router/node/root.rb:20:in `[]' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `block in call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `catch' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/http_router-0.8.11/lib/http_router.rb:110:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:796:in `route!' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/application/routing.rb:785:in `dispatch!' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:656:in `block in call!' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `block in invoke' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `catch' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:820:in `invoke' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:656:in `call!' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:641:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-flash-0.1.2/lib/rack/flash.rb:147:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/reloader.rb:243:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/logger.rb:300:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/showexceptions.rb:21:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/head.rb:9:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/showexceptions.rb:21:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1292:in `block in call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1323:in `synchronize' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/sinatra-1.2.7/lib/sinatra/base.rb:1292:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:71:in `block in call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `each' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/router.rb:64:in `call' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thin-1.2.11/lib/thin/server.rb:159:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/handler/thin.rb:13:in `run' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/rack-1.3.5/lib/rack/server.rb:265:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:44:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:34:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/server.rb:13:in `run!' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/cli/adapter.rb:7:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/lib/padrino-core/cli/base.rb:24:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/thor-0.14.6/lib/thor/base.rb:389:in `start' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/gems/padrino-core-0.10.0/bin/padrino:9:in `<top (required)>' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/bin/padrino:19:in `load' | |
/home/ethan/.rvm/gems/ruby-1.9.2-p290@fhsclock/bin/padrino:19:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment