メモ - Mongoid による MongoHQ へのアクセスの実験
ruby/rails で MongoDB を使うときのメジャーな選択肢として MongoMapper, Mongoid がありますが、
- Mongoid の方が後発、
- Mongoid の方が 2011/6 の段階で rails 3 対応、ドキュメントなどが充実しているらしい などの理由により、 Mogoid を使います。 (あまり詳しく調べてませんが、問題が発生したら乗り換えることもそんなに難しくないはず)
require 'sinatra' | |
require 'net/https' | |
client_id = '2044a7773387915a7a2a' | |
client_secret = 'secret' | |
get '/' do | |
html = <<-EOS | |
<html> | |
<head> |
# use node v0.7.4 | |
nvm 0.7.4 | |
# create a gemset for a sample application. | |
rvm gemset create scaffold_test | |
rvm gemset use scaffold_test | |
# install rails | |
gem install rails |
Parallel.each(last_infos, :in_threads => 4){ |last_info| | |
begin | |
Proc.new do | |
timeout(20) do | |
Peercast::Screenshot.new(last_info.url).download_to(download_path) | |
end | |
last_info.capture = download_path | |
last_info.save | |
end.retry(:max => 3, :accept_exception => Timeout::Error, :logger => Logger.new(STDERR)) |
git add -A && git commit -m "Generate with: $ $(fc -ln -1)" |
For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.
When creating a form with form_for
, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.
To allow new known fields to be added via JS, we could add:
This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.
Huge thanks to funny-falcon for the performance patches.
require 'eventmachine' | |
# most of code is from [thin-glazed](https://github.com/freelancing-god/thin-glazed) | |
class HttpClient < EventMachine::Connection | |
attr_reader :proxy | |
def initialize(proxy) | |
@proxy = proxy | |
@connected = EventMachine::DefaultDeferrable.new |
## Rails 3.2.1 (January 26, 2012) ## | |
* 変更なし |
javax.servlet.ServletContext log: unable to create shared application instance | |
org.jruby.rack.RackInitializationException: load error: ./config/boot -- java.lang.SecurityException: Google App Engine does not support Runtime.exec | |
from ./config/environment.rb:7 | |
from ./config/environment.rb:13:in `require' | |
from config.ru:13 |