NoBrainer is a Ruby ORM for RethinkDB.
The documentation can be found on http://nobrainer.io.
Ruby ORM for RethinkDB
Home Page: http://nobrainer.io/
License: Other
NoBrainer is a Ruby ORM for RethinkDB.
The documentation can be found on http://nobrainer.io.
Hi,
could you please with following issue rethinkdb/rethinkdb#2277 ? There are possible conflict with nobrainer and has_secure_password
Hi, I'm getting this error when I'm trying to save a new document.
class Boo include NoBrainer::Document field :name end
Then When I try to save after b = Boo.new(name: "bla")
I get this error
NoBrainer::Error::DocumentNotSaved: Expected type STRING but found BOOL. Query was: r.table("boos").insert( ^^^^^^^^^^^^^^^ r.json("{\"name\":\"bla\",\"id\":\"52d7dd451ece9410f3000002\"}") ) Erroneous_Portion_Constructed: from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/store_in.rb:32:in `rql_table' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/persistance.rb:102:in `insert_all' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/persistance.rb:35:in `_create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/callbacks.rb:15:in `block in _create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__3112139193626821377__create__callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_br from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner/write_error.rb:26:in `raise_write_error' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner/write_error.rb:18:in `rescue in call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner/write_error.rb:3:in `call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner/connection.rb:3:in `call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner/run_options.rb:33:in `call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/middleware-0.1.0/lib/middleware/runner.rb:31:in `call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/middleware-0.1.0/lib/middleware/builder.rb:102:in `call' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/query_runner.rb:23:in `run' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/nobrainer.rb:42:in `run' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/persistance.rb:102:in `insert_all' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/persistance.rb:35:in `_create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/callbacks.rb:15:in `block in _create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__3112139193626821377__create__callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/callbacks.rb:15:in `_create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/dirty.rb:15:in `_create' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/persistance.rb:63:in `save' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/callbacks.rb:23:in `block in save' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__3112139193626821377__save__callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/nobrainer-0.13.0/lib/no_brainer/document/callbacks.rb:23:in `save' from (irb):15 from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start' from /home/kushagr/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands.rb:64:in `' from bin/rails:4:in `require' from bin/rails:4:in `' In the nobrainer initializer my Rethinkdb_url is as follows: config.rethinkdb_url = "rethinkdb://localhost/#{Rails.application.class.parent_name}_#{Rails.env}"
Any Ideas as to why this might be happening would be great.
Do you have a list of features you'd like to see implemented?
Hey,
Any plans to implement joins and many-to-many relations?
Thanks.
Hi I get error when i try to use cucumber with rethinkdb connected via no-brainer.
Error:
No known ORM was detected! Is ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, Moped, or CouchPotato, Redis or Ohm loaded? (DatabaseCleaner::NoORMDetected)
Cucumber requires database cleaner as a gem . what do i do about this?
I'm trying to query for all records that have a nil value for a particular field (or I guess don't have that value set at all in the database). This doesn't work:
Model.where(:other_id.eq => nil)
Is this supported by NoBrainer?
Scenario
field :auth_token, index: true
field :auth
error: Error in src/buffer_cache/mirrored/mirrored.cc at line 178:
error: Guarantee failed: [data_token.has()]
error: Backtrace:
error: Wed Dec 18 20:15:07 2013
1: 0 rethinkdb 0x000000010a83833f _ZStlsIN2ql5sym_tEER15write_message_tS3_RKNSt3__16vectorIT_NS4_9allocatorIS6_EEEE + 753 at 0x10a83833f ()
2: 0 rethinkdb 0x000000010a46d146 _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 1962 at 0x10a46d146 ()
3: 0 rethinkdb 0x000000010a46d7a0 _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 3588 at 0x10a46d7a0 ()
4: 0 rethinkdb 0x000000010a46cdee _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 1106 at 0x10a46cdee ()
5: 0 rethinkdb 0x000000010a7178eb _ZNSt3__16vectorIhNS_9allocatorIhEEE8__appendEm + 8731 at 0x10a7178eb ()
6: 0 rethinkdb 0x000000010a48d466 _ZNSt3__112__deque_baseIyNS_9allocatorIyEEE5clearEv + 422 at 0x10a48d466 ()
7: 0 rethinkdb 0x000000010a49184a _ZN26callable_action_instance_tIN5boost3_bi6bind_tIvNS0_4_mfi3mf2Iv14mc_inner_buf_tbP14file_account_tEENS1_5list3INS1_5valueIPS5_EENSA_IbEENSA_IS7_EEEEEEE10run_actionEv + 28 at 0x10a49184a ()
8: 0 rethinkdb 0x000000010a466fb5 _ZN22linux_thread_message_tD0Ev + 885 at 0x10a466fb5 ()
error: Exiting.
Trace/BPT trap: 5
error: Error in src/buffer_cache/mirrored/mirrored.cc at line 425:
error: Unreachable code: No acceptable snapshotted version found for version 1
error: Backtrace:
error: Wed Dec 18 20:19:31 2013
1: 0 rethinkdb 0x00000001098e233f _ZStlsIN2ql5sym_tEER15write_message_tS3_RKNSt3__16vectorIT_NS4_9allocatorIS6_EEEE + 753 at 0x1098e233f ()
2: 0 rethinkdb 0x0000000109517146 _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 1962 at 0x109517146 ()
3: 0 rethinkdb 0x00000001095177a0 _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 3588 at 0x1095177a0 ()
4: 0 rethinkdb 0x0000000109516dee _ZNSt3__113__vector_baseIP20traversal_progress_tNS_9allocatorIS2_EEED2Ev + 1106 at 0x109516dee ()
5: 0 rethinkdb 0x00000001097c18eb _ZNSt3__16vectorIhNS_9allocatorIhEEE8__appendEm + 8731 at 0x1097c18eb ()
6: 0 rethinkdb 0x0000000109538246 _ZNSt3__112__deque_baseIyNS_9allocatorIyEEE5clearEv + 3974 at 0x109538246 ()
7: 0 rethinkdb 0x00000001095386c0 _ZNSt3__112__deque_baseIyNS_9allocatorIyEEE5clearEv + 5120 at 0x1095386c0 ()
8: 0 rethinkdb 0x00000001095385ab _ZNSt3__112__deque_baseIyNS_9allocatorIyEEE5clearEv + 4843 at 0x1095385ab ()
9: 0 rethinkdb 0x00000001095357b2 _ZNK4blob20region_tree_filler_tclEi + 232 at 0x1095357b2 ()
10: 0 rethinkdb 0x000000010953556e _Z4pmapIN4blob20region_tree_filler_tEEviRKT_ + 48 at 0x10953556e ()
11: 0 rethinkdb 0x0000000109533ed1 _ZN13btree_stats_tC2EP20perfmon_collection_tRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 2319 at 0x109533ed1 ()
12: 0 rethinkdb 0x0000000109533dfd _ZN13btree_stats_tC2EP20perfmon_collection_tRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 2107 at 0x109533dfd ()
13: 0 rethinkdb 0x00000001095340b8 _ZN13btree_stats_tC2EP20perfmon_collection_tRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 2806 at 0x1095340b8 ()
14: 0 rethinkdb 0x0000000109839c01 _ZNSt3__16__treeINS_4pairIN2ql5sym_tE9counted_tIKNS2_7datum_tEEEENS_19__map_value_compareIS3_S7_NS_4lessIS3_EELb1EEENS_9allocatorIS8_EEE12__find_equalIS8_EERPNS_16__tree_node_baseIPvEESL_RKT_ + 289 at 0x109839c01 ()
15: 0 rethinkdb 0x0000000109811c4f _ZN33post_construct_traversal_helper_t14process_a_leafEP16mc_transaction_tP13mc_buf_lock_tPK11btree_key_tS6_P8signal_tPi + 803 at 0x109811c4f ()
16: 0 rethinkdb 0x000000010952f8d7 _ZNSt3__114__split_bufferIN20const_buffer_group_t8buffer_tERNS_9allocatorIS2_EEEC2EmmS5_ + 1859 at 0x10952f8d7 ()
17: 0 rethinkdb 0x0000000109530c8c _ZN28do_a_subtree_traversal_fsm_t13on_node_readyEP12scoped_ptr_tI13mc_buf_lock_tE + 184 at 0x109530c8c ()
18: 0 rethinkdb 0x0000000109531cec _ZN20acquire_a_node_fsm_t15you_may_acquireEv + 116 at 0x109531cec ()
19: 0 rethinkdb 0x000000010953135e _ZN11coro_pool_tIP29acquisition_waiter_callback_tE10worker_runES1_N14auto_drainer_t6lock_tE + 68 at 0x10953135e ()
20: 0 rethinkdb 0x00000001095315b2 _ZNK5boost4_mfi3mf2Iv11coro_pool_tIP29acquisition_waiter_callback_tES4_N14auto_drainer_t6lock_tEEclEPS5_S4_S7_ + 68 at 0x1095315b2 ()
21: 0 rethinkdb 0x0000000109531544 _ZN5boost3_bi5list3INS0_5valueIP11coro_pool_tIP29acquisition_waiter_callback_tEEENS2_IS5_EENS2_IN14auto_drainer_t6lock_tEEEEclINS_4_mfi3mf2IvS6_S5_SB_EENS0_5list0EEEvNS0_4typeIvEERT_RT0_i + 58 at 0x109531544 ()
22: 0 rethinkdb 0x00000001095314ba _ZN26callable_action_instance_tIN5boost3_bi6bind_tIvNS0_4_mfi3mf2Iv11coro_pool_tIP29acquisition_waiter_callback_tES7_N14auto_drainer_t6lock_tEEENS1_5list3INS1_5valueIPS8_EENSD_IS7_EENSD_ISA_EEEEEEE10run_actionEv + 28 at 0x1095314ba ()
23: 0 rethinkdb 0x0000000109510fb5 _ZN22linux_thread_message_tD0Ev + 885 at 0x109510fb5 ()
error: Exiting.
Abort trap: 6
When we use first
and last
, we want the oldest and yougest document. With sql and mongodb, sorting by ID is sufficient as the IDs are monotonically increasing with time.
So should we generate our own IDs that would increase over time? Any other options?
I'm trying to set up a new application on Heroku with https://www.rethinkdbcloud.com/ and they provide the following env vars:
RETHINKDB_AUTH=xxx
RETHINKDB_HOST=xxx
RETHINKDB_PORT=xxx
Is there a way to build the url with the RETHINKDB_AUTH authKey? Would it be worth it to compose the url inside nobrainer if, for example, RETHINKDB_HOST is provided?
Is this planned?
I've added some type: Time fields to a model and present a form (text fields) for the values in Rails. The Rails form serializer returns empty strings (not nil) values for those attributes if they haven't been modified by the user. This results in " should be a time" validation errors, where the desired effect would be to store null values in the database.
Is there a way to force NoBrainer to accept empty strings as nil times and avoid these validation errors?
I haven't seen any way to configure NoBrainer to perform soft durability writes. This results in an order of magnitude performance increase on my dev machine, so I think it's a good option to have available.
Do you think it would be possible to allow this as a global configuration? A second option would be to allow it on a per query basis (like the driver does), but that seems less ideal.
people = NoBrainer.with_database('x') { Person.all }
@people = people.limit(search_size).skip((page-1) * search_size).to_a
Gives: RethinkDB::RqlRuntimeError - Database name `` invalid (Use A-Za-z0-9_ only).
people = Person.all
@people = NoBrainer.with_database('x') { people.limit(search_size).skip((page-1) * search_size).to_a }
Works ok
This example isn't too big a problem, except with the deferred execution nature of ActiveRecord, the principle of least surprise says that if you specify database anywhere, it should work whenever the query is actually resolved (especially as you often dont know where that is)
When performing JSON serialization on document instances, an exception will be raised if the document contains previously saved field value that have since been removed from the model declaration.
Example:
class Foo
include NoBrainer::Document
field :bar
end
foo = Foo.new bar: 'hello'
foo.save
Then we change the definition:
class Foo
include NoBrainer::Document
field :baz
end
foo = Foo.all.first
foo.to_json
will raise:
/Users/andy/.rvm/gems/ruby-2.1.0/gems/nobrainer-0.13.1/lib/no_brainer/document/attributes.rb:23:in `read_attribute': undefined method `bar' for #<Foo id: "53970edbcaa9d053d0000001", bar: "hello"> (NoMethodError)
What are your thoughts on allowing a proc that returns a default value for a belongs_to specification, like you can with a field? I know it seems a bit unusual, but I think there are some use cases where this really makes sense (especially in conjunction with the required option).
I haven't thought through the implementation in too much detail, but I can't see any particular issues with it.
In the first example, taken from the many to many issue where.include() was added #15 , there are 3 queries, but the join record and related record are both accessed
In the second example, the include is the same, causes three queries, and the join record can be accessed without another database call - but accessing the related record immediately after causes 2 more database queries
[9] pry(main)> User.includes(:machine_memberships => :machine).each do |user|
[9] pry(main)* user.machine_memberships.each do |p|
[9] pry(main)* puts p
[9] pry(main)* puts p.machine
[9] pry(main)* end
[9] pry(main)* end
r.db("master").table("users").orderby(r.asc("id"))
r.db("master").table("machine_memberships").filter {|var_2| var_2.get_field("user_id").eq("52b77cf42952f324c0000009")}.orderby(r.asc("id"))
r.db("master").table("machines").get_all( "52b77aa32952f324c0000004", {:index => "id"}).orderby(r.asc("id"))
#<MachineMembership:0x007f94ec3db160>
#<Machine:0x007f94ec49b140>
[5] pry(main)> x=User.includes(machine_memberships: :machine).first
r.db("master").table("users").orderby(r.asc("id")).limit(1)
r.db("master").table("machine_memberships").filter {|var_3| var_3.get_field("user_id").eq("52b77cf42952f324c0000009")}.orderby(r.asc("id"))
r.db("master").table("machines").get_all( "52b77aa32952f324c0000004", {:index => "id"}).orderby(r.asc("id"))
=> #<User id: "52b77cf42952f324c0000009", created_at: 2013-12-23 10:59:48 +1100, updated_at: 2013-12-23 11:56:50 +1100, email: "[email protected]", encrypted_password: "$2a$10$0GpbL4wTaWcdO8EfIMWYJOlkXSngNnmhl7YsXqqomEET9m81jkc4W", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 2, current_sign_in_at: 2013-12-23 00:02:50 +0000, last_sign_in_at: 2013-12-22 23:59:49 +0000, current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", first_name: nil, last_name: nil, provider: nil, is_admin: nil>
[6] pry(main)> x.machine_memberships.to_a
=> [#<MachineMembership id: "52b8c50a2952f33990000002", created_at: 2013-12-24 10:19:38 +1100, updated_at: 2013-12-24 10:19:38 +1100, machine_id: "52b77aa32952f324c0000004", user_id: "52b77cf42952f324c0000009", role: "owner">]
[7] pry(main)> x.machines.to_a
r.db("master").table("machine_memberships").filter {|var_4| var_4.get_field("user_id").eq("52b77cf42952f324c0000009")}.orderby(r.asc("id"))
r.db("master").table("machines").get_all( "52b77aa32952f324c0000004", {:index => "id"}).orderby(r.asc("id"))
=> [#<Machine id: "52b77aa32952f324c0000004", created_at: 2013-12-23 10:49:55 +1100, updated_at: 2013-12-23 13:29:56 +1100, name: "asdasd VBANAANA", description: nil, tags: ["a"]>]
What say ye to implementing something along the lines of Rails' Association Proxy which depends on Delegation for the dynamic method calls.
The Proxy would wrap the call to the NoBrainer::Selection, then a has_many
could provide:
Client.first.projects
=> [<#instance>, <#instance>, <#instance>]
instead of manually having to materialize the cursor
Client.first.projects.run.map { |x| x }
=> [<#instance>, <#instance>, <#instance>]
The with_database method passes the database name via the .run() command, meaning the query that is passed in does not match the query you would have to run in Data Explorer, or Javascript, or Python etc
Currently this leads to a misleading log output, but also it means it isn't easy to just test the query elsewhere
It should just prefix the table name with .db('x') to ensure the query is identical to the one actually run - this would massively help in debugging and diagnosing issues
I just updated to the latest NoBrainer from GitHub and now get the following error when trying to execute any query:
uninitialized constant RethinkDB::Term
I have the rethinkdb gem version 1.12.0.2
I can provide a full stack trace if needed. Any ideas?
Why no results returned through the console?
>> Event.where(action: 'created')
=> r.table("events").filter {|var_2| var_2.get_field("action").eq("created")}
>> Event.where("id LIKE '%?%' ?", '52b755')
=> #<NoBrainer::Criteria:0x007facb3f38650 @options={:root_rql=>r.table("events"), :klass=>Event}, @where_clauses=["id LIKE '%?%' ?", "52b755"], @order={}>
DEPRECATION WARNING: The `Validator#setup` instance method is deprecated and will be removed on Rails 4.2. Do your setup in the constructor instead:
class MyValidator < ActiveModel::Validator
def initialize(options={})
super
options[:class].send :attr_accessor, :custom_attribute
end
end
. (called from <class:Profile> at /Users/jocke/web/proj/app/models/profile.rb:5)
L5: field :username, required: true, unique: true
Running Rails 4.1.1
Rethink exposes these min/max queries:
r.table("users")["age"].max()
I don't see any way to do this in NoBrainer without dropping down to RQL. I think these would be good to have.
I didn't see a change log or history file in the project. I think it might be a good idea to add one to help people find out when features were added and removed.
I'm wondering about logging queries to some sort of output, specifically the rails output like Mongoid does. Am I correct that there's no support for this currently? Is this a feature people are interested in having (optional, of course)?
Hi, I've seem to have run into a problem.
My getters are firing up at object initialization.
For example User.new(name: "Robert")
is actually calling the getter for the name?
def name if super.blank? self.name = fetch_name_from_some_api self.save end return super end
Is this the intended behaviour.
Cause my code throws an error error cause there isn't an access_token from the api at initialization .
It didn't even occur to me that this was an ActiveRecord/Mongoid-specific method, as opposed to being included in ActiveModel, until I tried to use it this morning.
Here are the reference implementations for ActiveRecord and Mongoid, respectively:
https://github.com/mongoid/mongoid/blob/master/lib/mongoid/attributes/nested.rb
It's a bit unclear to me how easy it would be to simply borrow the Mongoid implementation.
Hi, I was shifting my rails application from mongoDB to rethinkDB.
I seem to have run in an issue with nobrainer.
My getters have stopped working and are throwing a stack level too deep error.
For example :
class User include NoBrainer::Document field :year def year self[:year] end end
Earlier with MongoDB this worked fine and only threw a stack level too deep error, when self[:year]
was replaced with self.year
(infinite recursion).
I wonder why this is not working with NoBrainer.
I'm looking into implementing the analog of Mongoid::Timestamps. However, it appears like NoBrainer currently has no support for specifying types on fields. For timestamps to be useful, we would need to be able to represent them as Date objects in Ruby, but correctly serialize and deserialize them to the database (as a string, I assume?).
Am I correct that there is currently no support for this in NoBrainer?
I might be missing something simple, but I can't figure out how to query on values in an Array. I have a model like so:
class Location
...
field :search_tags, type: Array
index :search_tags, multi: true
end
Then I try to find all locations with a certain string present in their search_tags array:
Location.where(search_tags: 'mn')
and I end up with this error:
NoBrainer::Error::InvalidType (search_tags should be used with a array. Got `mn`)
If I try to wrap 'mn' in an array, the query executes but returns nothing. I assume this is because it's looking for an exact match to the entire array.
Is there a way to do this without dropping down to the rethink query syntax?
This Event.order_by('created_at DESC')
raises please pass symbols, or hashes, not created_at DESC
Any objections to adding an optional concern to generate Paperclip fields? It seems like it could be implemented so that it only requires Paperclip if you use the concern. I know this is a rather trivial thing to add to your own code base, it just seems like it would be very useful to have available to everyone.
Hi, I'd rather not use Mongodb but having a hard time getting things work so I have a few questions.
NoMethodError at /api/events
============================
> undefined method `active_model_serializer' for #<Enumerator: r.table("events"):each>
app/controllers/api/v1/events_controller.rb, line 15
----------------------------------------------------
``` ruby
10
11 respond_to :json
12
13 # curl http://localhost:3024/api/events -H 'Authorization: Token token="your_token"'
14 def index
> 15 respond_with Event.all, root: false
17 end
respond_with Event.all
it fraises the following errorSystemStackError at /api/events
===============================
> stack level too deep
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb, line 70
----------------------------------------------------------------------
65 response[2] = ::Rack::BodyProxy.new(response[2]) { cleanup! }
66
67 response
68 rescue Exception
69 cleanup!
> 70 raise
71 end
72
73 def prepare! #:nodoc:
74 run_callbacks :prepare if validated?
75 end
Full backtrace
--------------
- actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:70:in `'
It seems assigning a value to a field (when it contains a hash) can leave the in memory record and the on disk one out of synch ...
machine = Machine.first
=> #<Machine id: "52b77aa32952f324c0000004", created_at: 2013-12-23 10:49:55 +1100, updated_at: 2013-12-23 13:26:37 +1100, name: "Machine1", machine_memberships: {"role"=>"owner"}>
machine.machine_memberships = {newthing: 'y'}
machine.save!
Machine.first
=> #<Machine id: "52b77aa32952f324c0000004", created_at: 2013-12-23 10:49:55 +1100, updated_at: 2013-12-23 13:29:56 +1100, name: "Machine1", machine_memberships: {"newthing"=>"y", "role"=>"owner"}>
machine
#<Machine id: "52b77aa32952f324c0000004", created_at: 2013-12-23 10:49:55 +1100, updated_at: 2013-12-23 13:29:56 +1100, name: "Machine1", machine_memberships: {"newthing"=>"y"}>
Hey,
Any plans to port this gem to work with rails4?
Thanks.
I think this just showed up in the last couple days:
cannot load such file -- no_brainer/document/association
/Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/autoload.rb:11:in const_get' /Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/autoload.rb:11:in
block in autoload_and_include'
/Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/autoload.rb:9:in each' /Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/autoload.rb:9:in
autoload_and_include'
/Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/document.rb:7:in <module:Document>' /Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-2dd335196662/lib/no_brainer/document.rb:3:in
<top (required)>'
Any way to do this in Nobrainer?
According to the documentation, the 'has_many' and 'belongs_to' don't support the normal Rails attributes to enable this
class Profile
...
index :type, ->(doc){ doc['id'].nth(0) }
irb(main):002:0> Profile.where(type: 'admin').count
[3660.9ms] r.table("profiles").get_all("admin", {"index" => :type}).orderby( r(:id).asc).count RethinkDB::RqlRuntimeError Array over size limit 100000.
RethinkDB::RqlRuntimeError: Array over size limit 100000.
Backtrace:
r.table("profiles").get_all("admin", {"index" => :type}).orderby(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
r(:id).asc
^^^^^^^^^^
).count
This works as expected:
NoBrainer.run { |r| r.table('profiles').get_all('admin', index: 'type').count }
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can image, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
I'm accessing document metadata with Document.fields and I don't see created_at or updated_at (I have not disabled timestamps in the config).
When sending #[sym]
or #attributes[sym]
to a document, return the attribute value without calling the method with the same name. This is how Active Record does it.
Currently (lib/no_brainer/document/attributes.rb):
def read_attribute(name)
__send__("#{name}")
end
def [](*args); read_attribute(*args); end
This opens up the possibility of modifying the value on call:
def links
self[:links].map { |l| l.downcase }
end
Why can't we use the standard Rails declaration?
validates_uniqueness_of :name
=> undefined method `validates_uniqueness_of' for Agent:Class
validates_uniqueness_of :name, scope: :environment
=> undefined method `validates_uniqueness_of' for Agent:Class
The following validates :name, uniqueness: {scope: :environment}
has no effect in the sense where it 'saves' (no error reported) but it doesn't update column (which is good)
There appears to be major api changes from 1.2 to 1.4. I'm sorry for the lazy issue but I can't figure out what changed. It appears that Rethink::RQL has changed along with the 1.4 release although I couldn't find any mention of it in the changelog blog post.
database.rb:11:in `raw': undefined method `db' for
RethinkDB::RQL:Class (NoMethodError)
Using 1.2 drivers against a 1.4 server causes a disconnect:
RuntimeError: Connection closed by server!
from ... rethinkdb-1.2.6.1/lib/net.rb:99
Hi , I'm facing the following issue, any pointers ?
class User include NoBrainer::Document has_many :friends end
class Friend include NoBrainer::Document belongs_to :user end
friend = Friend.create
user = User.create
Now When I go ahead and do
user.friends << friend
I get a frozen Array error , is this intended ?
I'm just about to use Rethink on a major Rails project, and while some aspects of Nobrainer look great, I'm a little unclear about it's current state, and the roadmap going forwards (if there is one)
It seemed to be abandoned when I looked at it a few weeks ago, but some recent changes/fixes have appeared
Can anyone give some guidance/advice? Maybe update the Readme with the state of the gem?
Ongoing development would seem especially important as Rethink is undergoing such major changes right now
Is it not possible to define an arbitrary index as multi using Nobrainer? I have tried the following, to no avail:
index :emails_index, ->(doc) {
doc[:emails].map(->(emails) {
emails.map(->(email) {
email[:email]
})
})
}, multi: true
I receive no errors, the index is created correctly sans the multi declaration.
However, if I create the index using ReQL:
r.db('pulse').table('contacts').indexCreate('emails_index', function(contact) {
return contact('emails').map(function(email) {
return email('email');
})
}, {multi: true});
Things behave as they should. I'm a little perplexed; is there something wrong with the way I have defined the index (using nobrainer), or is this a bug?
Is there a validation option for uniqueness checking? similar to ActiveRecord's validates_uniqueness_of, validation in Rails..
Is there any way at runtime to declare a field on a model?
My current requirement is for a user defined schema (the system has a Contact record, but each user of the system can define their own data fields on the Contact)
Rethink looks to be a good option for this, and while investigating, I came across nobrainer and wondered if this was possible
SystemStackError - stack level too deep:
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:70:in `'
Seems to be caused by passing a params hash to .new() with attributes that are not defined as fields on the model
I had presumed that passing attributes to .new would also allow them to be used via Dynamic Attributes, but it appears not (either due to this error, or for some other reason)
It is also caused by x.attributes=params (when there are params that do not have defined fields)
IF I include the following into my 'Person' model:
include NoBrainer::Document
include NoBrainer::Document::DynamicAttributes
Then I get an error: uninitialized constant Person::NoBrainer::Document
If I remove the include NoBrainer::Document::DynamicAttributes it works OK (but obviously with no dynamic attributes)
If I reverse the order of the includes, I get no error, but no dynamic attributes either
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.