2012-09-07 16 views
1

下面是我的應用程序 -爲什麼戒指會給我錯誤的迴應?

(ns mfaiz.routes 
    (:use [net.cgrand.moustache :only [app]] 
     [net.cgrand.enlive-html :only [deftemplate content]] 
     [ring.util.response :only [response]])) 

(deftemplate reg "mfaiz/templates/reg.html" []) 

(def my-app (app 
      ["hi"] "Hello World!" 
      ["reg"] (-> ((-> "reg" symbol resolve)) response constantly) 
      [&] "Nothing was found")) 

我遇到的錯誤與這條路線 -

["reg"] (-> ((-> "reg" symbol resolve)) response constantly) 

如果我直接評價上面的路線,它工作正常,並返回HTML文件 -

((-> "reg" symbol resolve)) 

如果我也改變路線直接調用模板功能,那麼它也可以工作 -

["reg"] (-> (reg) response constantly) 

任何想法出了什麼問題?

+1

嘗試使用'( - >「mfaiz.routes/reg」符號解析)' – Ankur

+0

@Ankur謝謝,這就像一個魅力! Ankur爲什麼需要在ns中存在符號時指定ns。此外,評估是成功的,沒有納稅資格,爲什麼呢? – murtaza52

+0

你也可以將它作爲答案發布,我會標記它。 – murtaza52

回答

1

這個問題似乎是在環下運行時,「reg」沒有被解析,因爲它沒有完全合格。這取決於環服務器在哪個命名空間啓動。因此,使用完全合格的名稱將工作:

(-> "mfaiz.routes/reg" symbol resolve)

請檢查resolvedocumentation。它試圖解析當前名稱空間中的符號,即*ns*

相關問題