Re: [DataMapper] Where to find documentation for the finder methods for DataMapper objects?
Dan, Most of the documentation is in the same page you mention. Although it explains in detail all options you can use when calling: Model.all Model.get(id) will get you a single record from the database Model.first will get you the first record from the database... or depending if there's a default scope defined, the first record this scope returns Model.last will get you the last record from the database... or depending if there's a default scope defined, the last record this scope returns Both :first and :last can be used with a scope defined in your model to retrieve either the first or last record from that specific collection. On Fri, Apr 18, 2014 at 2:09 PM, Dan Tenenbaum wrote: > Hello, > > The page at > > http://datamapper.org/docs/find.html > > says: > > "The finder methods for DataMapper objects are defined in > DataMapper::Repository. They include #get, #all, #first, #last" > > with a link to > > http://rubydoc.info/github/datamapper/dm-core/master/DataMapper/Repository > > However, on that page, there is no documentation for anything with the > specified names. > > And using the search box to search for methods called 'find' returns no > exact matches. > > Where's the documentation I'm looking for? > > Thanks, > DAn > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper. For more options, visit https://groups.google.com/d/optout.
Re: [DataMapper] property uniqueness with scope
I know this is something you probably already done, but are you completely sure you're loading dm-validations in your application.rb file (or wherever you're loading datamapper)? make sure you have this line: require "dm-validations" On Wed, Feb 19, 2014 at 8:10 AM, Nicholas Wieland wrote: > Hi, I'm having a very strange issue I'm not quite able to understand: > > https://gist.github.com/ngw/9954447e04b0f60b1f86 > > The problem I have is that the spec fails, the subquery I create is valid > (and it shouldn't, text is not unique) and I don't understand why. > Using unique: true doesn't help. > > What am I doing wrong? > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper. For more options, visit https://groups.google.com/groups/opt_out.
Re: [DataMapper] Newbie: datamapper doesn't tell me why I fail to save
Could you show some code? How's your model declared and how are you instantiating a new object and then saving it? On Jun 14, 2013 8:31 AM, "Charles Monteiro" wrote: > its odd, I have turned on errors and I get the following: > > DataMapper::SaveFailureError: Project#save returned false, Project was not > saved > > not telling me much. > > I check the error hash and that's empty. > > How does a newbie understand what dependencies etc I'm not fulfilling in > the creation of an object. > > BTW, in case it matters I'm creating an object just by new and then > sending save. This object does have associations so I'm assuming that's > where the issue but I really would like to know what Datamapper thinks is > the problem. Currently, I'm confused as to why its not saving. > > Any feedback is appreciated. > > thanks > > -Charles > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper. For more options, visit https://groups.google.com/groups/opt_out.
Re: [DataMapper] Decimal datatype
You are asigning foo to the name field... and nothing to the data field... in your model, you declared data as a requires field... if you don't assign anything to it, it's nil... and data must have a value... that's why. On May 23, 2013 11:18 AM, "Nicholas Wieland" wrote: > Hi *, I have a model like this: > > class Trait > include DataMapper::Resource > > property :id, Serial > property :name, Slug, :required => true > property :data, Decimal, :required => true > > has n, :items, :through => :assignments > has n, :assignments > end > > and if I do: > > irb(main):029:0> t = Trait.new > => # > irb(main):030:0> t.data = 1.0 > => 1.0 > irb(main):031:0> t > => # > irb(main):032:0> t.name = "FOO" > => "FOO" > irb(main):033:0> t > => # > irb(main):034:0> t.save > => false > irb(main):035:0> t.errors.inspect > => "# @resource=#, @errors={:data=>[\"Data > must not be blank\"]}>" > > can someone explain me why I'm not able to set the data attribute? > > TIA, > ngw > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [DataMapper] Adding custom methods to a model ?
what you're doing there is defining a class method named more_than_fifty? a method declared like that can be called from the class itself, not an instance of it. So, you end up with: Day.more_than_fifty? instead of: day = Day.new day.more_tan_fifty? to add instance methods to a class, just declare them like this: def method_name # do something end that is, without using self On Thu, Mar 7, 2013 at 9:55 AM, Pierre-Adrien Buisson wrote: > Hey guys, > > I'm beginning with Sinatra and using DataMapper as my ORM tool of choice. > I've been doing great, playing with this today, but I'm now stuck. I'd like > to add a custom method to one of my models, that would check some values of > an instance, make some comparisons and return a boolean. > > I tried the following : > > class Day > include DataMapper::Resource > > property :id, Serial > property :day_number, Integer > property :status, Integer, :default => 0 > property :date, Date > * > def self.more_than_fifty? > # Just for the sake of the example > rand(1..100) > 50 > end* > end > > But didn't work. I've seen one or two cryptic messages on Stack Overflow > about DataMapper::Model.append_inclusions, but not enough for me to > understand and get it working. > Anyone who could help me around here ? Thanks a lot for your time guys. > > Paddy > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [DataMapper] data_mapper 0.9.11
Michael, Syntax for installing a particular version is: gem install data-mapper -v 0.9.11 On Oct 5, 2012 8:39 AM, "Michael Mitchell" wrote: > Hi, > I've come to data_mapper via a programming book that uses version 0.9.11 > (in the building of several sinatra applications). I tried to run the > code from the book using the latest version of data mapper but it doesn't > work. Is there a way to install the older version of data_mapper and to > make sure that all the right versions of the dependencies are installed > too? The code uses gems like dm-core, dm-timestamps etc. > > a) will I need to install the older version of each of these gems > individually? > > b) can you please give me the exact syntax to use > > For example, I tried > > gem install data_mapper-0-9-11 > > > but it said it couldn't be found > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/datamapper/-/OFScvvG-KSEJ. > To post to this group, send email to datamapper@googlegroups.com. > To unsubscribe from this group, send email to > datamapper+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.