Code Monkey home page Code Monkey logo

simply_stored's People

Contributors

akm avatar bterkuile avatar jweiss avatar kreuzer7 avatar peritor avatar roidrage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

simply_stored's Issues

validates_inclustion_of => NoMethodError

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

name error on hbtm rel when class name has trailing S's

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'.

find without dynamic finder

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

simply_stored does not appear to be compatible with ruby 1.9.2

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

Exception on comparison with foreign object

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.

CouchDB and SimplyStored

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)='

Association classname?

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 - Error

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'

linked documents feature (feature request)

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

uninitialized constant when using custom has_many association

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

SimpleObject.last not implemented

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

Entity classe nested inside the module results in invalid method name being generated

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.

find_by_fixnum expects string parameter

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 >

Uninitialized constant errors in Rails 3 Model classes

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.

validate_numericality_of 'property quantity, :type => Fixnum' not as expected

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.

User.first returns an hash

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.

duplicate property names cause mystifying error message

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.