The name 'user' is taken from an example in the book. The author executes the code at the REPL like this:
(require '(active-record [user :as user])) user=> (user/create {:login "rob" :first_name "Robert" :last_name "Berger" :password "secret" :email_address "r...@runa.com"}) And then there is the clj-record macro 'init-model' that creates a model out of a Clojure namespace. However, I don't quite understand how this affects bringing in the namespaces. Here is the code: http://github.com/duelinmarkers/clj-record/blob/master/src/clj_record/core.clj (at the bottom) On Oct 20, 4:20 pm, Michael Wood <esiot...@gmail.com> wrote: > On 20 October 2010 10:09, Stefan Rohlfing <stefan.rohlf...@gmail.com> wrote: > > > > > > > > > > > Dear Clojure group, > > > I am currently reading chapter 9.1 MySQL & clj-record of 'Clojure in > > Action'. > > > clj-record seems pretty awesome, but I once again got lost in > > namespace jungle. > > > Here is a concrete example: > > > --------------------------------------------------------------------------- > > ----- > > > File 1: src/active-record/credentials.clj > > [Database credentials] > > > (ns active-record.credentials) > > > (def db > > {:classname "com.mysql.jdbc.Driver" > > :subprotocol "mysql" > > :user "xxxx" > > :password "xxxx" > > :subname "//localhost:3306/damages_dev" > > }) > > > --------------------------------------------------------------------------- > > ----- > > > File 2: src/active-record/user.clj > > [Belongs to the database name with the name 'users'] > > > (ns active-record.user > > (:use [active-record.credentials :only [db]]) > > (:require clj-record.boot)) > > > (clj-record.core/init-model > > (:associations > > (has-many charges))) > > > --------------------------------------------------------------------------- > > ----- > > > File 3: src/active-record/charge.clj > > [Belongs to the database name with the name 'charges'] > > > (ns active-record.user > > (:use [active-record.credentials :only [db]]) > > (:require clj-record.boot)) > > > (clj-record.core/init-model > > (:associations > > (has-many charges))) > > > --------------------------------------------------------------------------- > > ----- > > > I want to add/remove/alter table entries in a different file: > > > File 4: src/active-record/program/core.clj > > > All my efforts to import the user.clj and charge.clj namespaces have > > failed so far. For example, I have tried the following namespace > > declaration: > > > (ns active-record.program.core > > (:require [active-record.user :as user]) > > Just a guess, but try something other than "user". The user namespace > is the default namespace when using the repl and maybe there's some > sort of conflict there. > > I'm not sure how likely that is, but it's worth a try, I think :) > > > > > > > > > > > (:require [active-record.charge :as charge]) > > (:require clj-record.boot)) > > > (user/create > > {:login "rob" > > :first_name "Robert" > > :last_name "Berger" > > :password "secret" > > :email_address "r...@runa.com"}) > > > ;; No such var: user/create > > ;; [Thrown class java.lang.Exception] > > > This one doesn't work either: > > > (ns active-record.program.core > > (:require [active-record.user :as user]) > > (:require [active-record.charge :as charge])) > > > ;; EOF while reading > > ;; [Thrown class java.lang.Exception] > > > Can anybody tell me what went wrong in the example above? > > -- > Michael Wood <esiot...@gmail.com> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en