peritor / simply_stored Goto Github PK
View Code? Open in Web Editor NEWA convenience wrapper around CouchDB (using CouchPotato) that supports relations and S3 attachments
License: Other
A convenience wrapper around CouchDB (using CouchPotato) that supports relations and S3 attachments
License: Other
Hi,
the following class
class Account
include SimplyStored::Couch
property :name
property :type
validates_inclusion_of :type, :in => ["a","b"]
end
leads to following error :
undefined method `add_validations' for Account:Class
the following works fine:
validates_presence_of :type
my configuration: rails 3.0.0, ruby 1.8.7, gem 1.3.7, simply_stored 0.3.8, validatable 1.6.7
To reproduce:
class Department
include SimplyStored::Couch
has_and_belongs_to_many :losses, :storing_keys => true, :class_name => 'Loss'
end
class Loss
include SimplyStored::Couch
has_and_belongs_to_many :departments, :storing_keys => true, :class_name => 'Department'
end
when calling, a_department.losses we get an uninizialized constant error, that it can't find 'Los'
This occurs when in get_class_from_name we pass in the class name of 'Loss' and when calling classify on 'Loss' it shrinks it to 'Los'.
hi...this is a pretty noob question....when I use find_by_email I get:
Warning: Defining view User#by_email with keys "email" at call time, please add it to the class body...
I don't know what must I do and use a method in call time result very slow and I'm used to datamapper style finder; there are any way for find whitout dynamic finder; I've tried it:
user=User.first(:name => "gaga") nice style datamapper
or
user=User.find(:first, :condition =>{:name => "gaga"}) ugly old rails version
but any work
thanks
Forgive me if this is stated some place else in the docs. I looked and couldn't find any information regarding version compatibility.
Ruby 1.9.2-p180
Ubuntu 10.04
simply_stored (0.5.0)
Stack:
scottw@cvgweavers02-linuxvm:~/Projects/o2o-accelerator$ bundle exec rspec spec/
/home/scottw/.rvm/gems/ruby-1.9.2-p180/gems/simply_stored-0.5.0/lib/simply_stored/couch.rb:13:in `require': /home/scottw/.rvm/gems/ruby-1.9.2-p180/gems/simply_stored-0.5.0/lib/simply_stored/couch/finders.rb:45: syntax error, unexpected tSTAR, expecting ')' (SyntaxError)
find(:first, :order => :desc, *args)
^
/home/scottw/.rvm/gems/ruby-1.9.2-p180/gems/simply_stored-0.5.0/lib/simply_stored/couch/finders.rb:60: syntax error, unexpected $end, expecting keyword_end
The same thing happens when irb when attempting "require 'simply_stored''
I found this reference: https://gist.github.com/137401 (last entry) which indicates the above is indeed unsupported in Ruby 1.9. There is also this post: http://www.ruby-forum.com/topic/136408
I ran into this error when I was doing an myarray.include?(:some_symbol)
myarray holds some SimplyStored Documents ... when comparing of those it raises an
undefined method `_id' for :mySymbol:Symbol
/usr/lib/ruby/gems/1.8/gems/simply_stored-0.3.6/lib/simply_stored/instance_methods.rb:11:in `=='
this comes as the equals method (==) does not check whether other is an simply stored object. So any object is asked for its _id-method which of course is not available for objects of foreign classes.
So instead of
def ==(other)
other._id == _id && other._rev == _rev
end
just do
def ==(other)
other.kind_of?(SimplyStored::Couch) && other._id == _id && other._rev == _rev
end
and the problem is solved.
This was fixed in the 0.6.0 of couch_potato to make it compatible with rails 3.1, since simply_stored is using 0.5.7 the issue is there.
See for reference:
langalex/couch_potato#39
langalex/couch_potato#40
dozeo/couch_potato@0ff2323#L1L173
Dears, i was trying SimplyStored with CouchDB today with rails master and simply_stored master
after configure and running i got the following :
firstly, when calling the index method of the model "localhost:3000/posts" .. its shows RestClient::RequestTimeout (Request Time Out).
when trying to create a model which have Date property as :type => Date or :type => :date
i got the following undefined method `start_date(1i)='
Is there any way to have more then on association point to another simply stored item?
IE can we do the following:
class Document
include SimplyStored::Couch
belongs_to :creator, :classname => "User"
belongs_to :updater, :classname => "User"
end
CouchDB - Custom Associations
class Document
include SimplyStored::Couch
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
end
d = Document.new
d.creator = User.first
leads to following error :
ArgumentError: wrong number of arguments (2 for 1) in `belongs_to'
since .11, couchdb supports the notion of linked documents (emitting _id). it would be beneficial if the default views would leverage this to fetch associated documents
Taking the example from the fixtures file in the simply_stored tests for User and Document.
When doing a_user.add_doc a_document, we get a 'NameError: uninitialized constant Doc'
Because in https://github.com/peritor/simply_stored/blob/master/lib/simply_stored/couch/has_many.rb#L61 we call simply_stored/class_methods_base.rb:5:in `get_class_from_name'" and then we are passing in 'docs' instead of the custom specified :class_name of Document.
So when defining the setter for has_many, it thinks that the class name is Doc instead of Document.
Here's a console output of this issue: https://gist.github.com/1304852
I have found that in simply_stored/lib/simply_stored/couch/finders.rb there is a :first method implemented, so I can fetch the first record of that type. Working.
But I am missing a :last method allowing me, to get the last record ...
should be something like
def last(*args) find(:last, *args) end
as the first query is made via
CouchPotato.database.view(all_documents(:limit => 1)).first
it seems that a performant approach has to look different for last as for first as we cannot use that :limit => 1 here
when I try to persist an instance of the entity class defined inside the module, I'm getting following exception:
c:/Ruby/Ruby-1.9.2/lib/ruby/gems/1.9.1/gems/couch_potato-0.4.0/lib/couch_potato/view/custom_views.rb:34:in `instance_eval': (eval):1: syntax error, unexpected '/', expecting ';' or '\n' (SyntaxError)
def association_th_shop/product_belongs_to_supplier(v...
^
(eval):1: syntax error, unexpected keyword_end, expecting $end
...upplier", view_parameters); end
... ^
from c:/Ruby/Ruby-1.9.2/lib/ruby/gems/1.9.1/gems/couch_potato-0.4.0/lib/couch_potato/view/custom_views.rb:34:in `view'
from c:/Ruby/Ruby-1.9.2/lib/ruby/gems/1.9.1/gems/simply_stored-0.5.3/lib/simply_stored/couch/belongs_to.rb:24:in `belongs_to'
...
here is my entity class:
module ThShop
class Product
include SimplyStored::Couch
belongs_to :supplier
end
end
apparently, the problem is in the slash character inserted into the method name.
I'm using simply_stored 0.5.3 with Ruby 1.9.2-p180 on Windows.
The generated find_by view doesn't know that my field is a Fixnum. Is that possible with simply_stored?
class Product
include SimplyStored::Couch
property :quantity, :type => Fixnum, :default => 0
validates_numericality_of :quantity, :allow_nil => true
end
Product.find_by_quantity(123) # => nil
Product.find_by_quantity("123") # => #<Product (etc.) quantity: 123 >
I'm new to Rails 3 and simply_stored. When I try to create a Model class (such as User) with the line 'include SimplyStored::Couch', I get an error:
class:User': uninitialized constant User::SimplyStored (NameError)".
In the 'Usage' section of your website, it says to include the lines:
require 'simply_stored/couch'
CouchPotato::Config.database_name = 'couchdb_test'
But I'm not sure where these should go. I've tried putting them in a file 'config/couchdb.rb', and in the Gemfile, but it doesn't make any difference.
I'm using Rails 3.0.0.rc2, simply_stored 0.3.9, couch_potato 0.4.0, couchrest 1.0.1, and CouchDB 1.0.1, running on Windows XP SP3.
Thanks for your help.
I have a form with a text field, for which I'd like to validate the contents as numerical.
Unfortunately, properties defined with a type are typecast on assignment (this is couch_potato behavoir, I believe). So if I assign a string to a property of type Fixnum, the value is typecast (meaninglessly) to 0.
class Product
include SimplyStored::Couch
include Validatable
property :quantity, :type => Fixnum
validates_numericality_of :quantity
end
p= Product.new(:quantity => "not a number")
p.valid? # => true
p.quantity # => 0
Has anyone else come across this? Any advice on how to handle this? It seems like it might be reasonable behavior from the perspective of couch_potato, which has something like 'statically typed' attributes. But it certainly doesn't make sense in the context of validations.
Model.first or any other db call returns an hash.
res = Model.first
res.name wont work.
But documentation says, we can make res.name call.
And also can I know how to update a record.
this is more of a usability thing. i accidentally defined a property and a belongs_to with the same name. the resulting error message was 'undefined method `options' for #CouchPotato::Persistence::SimpleProperty:0x17e581f9'
maybe this makes sense to seasoned ruby-ists, but it threw me off for a bit.
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.