I have a problem using persistent and Yesod with postgresql. This is the function that brings problems:
postBlogR :: MyHandler Html
postBlogR = do
((res, widgetForm), enctype) <- runFormPost blogForm
case res of
FormSuccess blog -> do
blogId <- runDB $ insert blog
redirect $ HomeR
_ -> adminLayout [whamlet|<h1>Post Created!|]
The trace is:
* Couldn't match type `BaseBackend(YesodPersistBackend PersonalPage)'
with `SqlBackend'
arising from a use of `insert'
* In the second argument of `($)', namely `insert blog'
In a stmt of a 'do' block: blogId <- runDB $ insert blog
In the expression:
do { blogId <- runDB $ insert blog;
redirect $ HomeR }
You are missing the relevant YesodPerist
instance. It will be something like this:
instance YesodPersist App where
type YesodPersistBackend App = SqlBackend
runDB action = do
master <- getYesod
runSqlPool action $ appConnPool master