Skip to content

Instantly share code, notes, and snippets.

View ngw's full-sized avatar

Nicholas Wieland ngw

View GitHub Profile
@user.update_attributes :email => params[ :user ][ :email ], :name => params[ :user ][ :name ]
## ERROR
Access to the collection for Answer is not allowed since it is an embedded document, please access a collection from the root document.
[ngw@slicingupeyeballs:~/foora]$ rails c (01-24 15:17)
Loading development environment (Rails 3.0.3)
ruby-1.8.7-p330 :001 > u = User.last
=> #<User _id: 4d385c454fcb065289000006, name: "Nicholas Wieland", following_ids: nil, last_sign_in_ip: "127.0.0.1", last_sign_in_at: Sun Jan 23 09:58:33 UTC 2011, sign_in_count: 7, current_sign_in_ip: "127.0.0.1", remember_token: "SQwUb1kLBLJQ0kj41UmF", authentication_token: nil, current_sign_in_at: Mon Jan 24 13:01:12 UTC 2011, remember_created_at: Thu Jan 20 16:03:29 UTC 2011, invitation_sent_at: Thu Jan 20 16:01:10 UTC 2011, email: "nicholas.wieland@gmail.com", invitation_token: "Yj8FgssfXC20PfEpn0LJ">
ruby-1.8.7-p330 :002 > u.update_attributes :email => 'ngw@nofeed.org'
Mongoid::Errors::InvalidCollection: Access to the collection for Answer is not allowed since it is an embedded document, please access a collection from the root document.
from /Users/ngw/.rvm/gems/ruby-1.8.7-p330/bundler/gems/mongoid-8af3b6ace655/lib/mongoid/collections.rb:2
class Design
include Mongoid::Document
include Mongoid::Slug
mount_uploader :thumbnail, ThumbnailUploader
mount_uploader :screenshot, ScreenshotUploader
field :url, :type => String
field :client, :type => String
class PortfolioGenerationJob
@queue = :generation
class << self
def perform subdomain
puts subdomain
end
def before_perform_log *args
ENV[ "RAILS_ENV" ] ||= 'test'
require File.expand_path( "../../config/environment", __FILE__ )
require 'rspec/rails'
require 'factory_girl'
require 'carrierwave/test/matchers'
require 'fakefs/spec_helpers'
Dir[ Rails.root.join( "spec/support/**/*.rb" ) ].each { |f| require f }
Dir[ Rails.root.join( "spec/factories/*.rb" ) ].each { |f| require f }
ruby-1.9.2-p180 :001 > Resque.enqueue( PortfolioGenerator, 'test' )
=> [{:klass=>PortfolioGenerator, :args=>["test"]}]
ruby-1.9.2-p180 :002 > Resque::Job.create Resque.queue_from_class( PortfolioGenerator ), PortfolioGenerator, 'test'
=> 1
## call to enqueue, doesn't even write on redis
def create
if @portfolio = current_user.create_portfolio( params[ :portfolio ] )
Resque.enqueue( PortfolioGenerator, current_user.subdomain )
redirect_to root_path
else
render :new
end
end
class Otcho < Sinatra::Base
register Sinatra::Async
apost '/:subodomain.json' do |subdomain|
body { puts request.body.string }
end
end
>> class Foo
>> def initialize arg
>> @attr = arg
>> end
>> attr_accessor :attr
>> def attr=( arg )
>> puts 'HA!'
>> end
>> end
>> Foo.new 'test'
>> class Foo
>> def initialize arg
>> @attr = arg
>> end
>> def attr=( arg )
>> puts 'HA!'
>> end
>> end
=> nil
>> Foo.new 'test'