摘要: main = defaultMain[ bench "bigTable html" $ nf bigTableHtml bigTableData, bench "bigTable hamlet" $ nf bigTableHamlet bigTableData, bench "bigTable widget" $ nf bigTableWidget bigTableData, bench "bigTable blaze" $ nf bigTableBlaze bigTableData]whererows :: In 阅读全文
posted @ 2012-03-19 11:41 kelby 阅读(216) 评论(0) 推荐(0) 编辑
摘要: getAuth :: a -> AuthgetAuth = const Auth-- | User credentialsdata Creds m = Creds{ credsPlugin :: Text -- ^ How the user was authenticated, credsIdent :: Text -- ^ Identifier. Exact meaning depends on plugin., credsExtra :: [(Text, Text)]}class (Yesod m, PathPiece (AuthId m), RenderMessage m Form 阅读全文
posted @ 2012-03-19 11:38 kelby 阅读(399) 评论(0) 推荐(0) 编辑
摘要: mkPersist [$persist|Emailemail String Eqstatus Bool updateverkey String null updatepassword String null updateUniqueEmail email|]data A2 = A2 { connPool :: ConnectionPool }mkYesod "A2" [$parseRoutes|/auth AuthR Auth getAuth|]instance Yesod A2 where approot _ = "http://localhost:3000&q 阅读全文
posted @ 2012-03-19 11:36 kelby 阅读(299) 评论(0) 推荐(0) 编辑
摘要: getRootR :: Handler ()getRootR = redirect RedirectTemporary $ AuthR LoginRgetAfterLoginR :: Handler RepHtmlgetAfterLoginR = domauth <- maybeAuthIddefaultLayout $ addHamlet [hamlet|<p>Auth: #{show mauth}|]instance Yesod BID whereapproot _ = "http://localhost:3000"instance YesodAuth 阅读全文
posted @ 2012-03-19 11:33 kelby 阅读(190) 评论(0) 推荐(0) 编辑
摘要: getRootR :: Handler RepHtmlgetRootR = getAfterLoginRgetAfterLoginR :: Handler RepHtmlgetAfterLoginR = domauth <- maybeAuthIddefaultLayout $ addHamlet [hamlet|<p>Auth: #{show mauth}$maybe _ <- mauth<p><a href=@{AuthR LogoutR}>Logout$nothing<p><a href=@{AuthR LoginR}&g 阅读全文
posted @ 2012-03-19 11:32 kelby 阅读(239) 评论(0) 推荐(0) 编辑
摘要: oauthUrl :: Text -> AuthRouteoauthUrl name = PluginR name ["forward"]authOAuth :: YesodAuth m=> OAuth -- ^ 'OAuth' data-type for signing.-> (Credential -> IO (Creds m)) -- ^ How to extract ident. -> AuthPlugin mauthOAuth oauth mkCreds = AuthPlugin name dispatch login 阅读全文
posted @ 2012-03-19 11:29 kelby 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 对于下面的这几行,比较难理解,有空再说吧。Our first attempt to do this would be:class ProjectsController < InheritedResources::Base def update update! do |format| unless @project.errors.empty? # failure format.html { redirect_to project_url(@project) } end end endendLooks too verbose, right? We c... 阅读全文
posted @ 2012-02-24 19:13 kelby 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 对下面两个插件有依赖,分别为 HasScope 和 Responders 他们三者安装都很简单,直接 gem install 或者 bundle 就行。对于 controller 中,常见的 flash 提示如 flash[:success] , flash[:failure] 我们可以用 Responders 聪明的我们减少重复造轮子Using responders will set the flash message to :notice and :alert. You can change that through the following configuration value:In 阅读全文
posted @ 2012-02-24 18:51 kelby 阅读(402) 评论(0) 推荐(0) 编辑
摘要: 对于新手来说,安装rails有时确实是一件痛苦的事。这也不懂,那也不懂。尽管网上这教程一搜一大把,但如何‘选择’又是另一个大问题了。 网上教你如何安装rails的教程可以说数不胜数,这也只是其中这一,作者希望能够对你有帮助~~~ 首先说明,这教程不适用于windows,作者本人也只是在ubuntu上安装成功,其它的类linux应该‘大同小异’吧。 第一步,打开终端Ctrl+T。 然后升级一下源,执行: sudo apt-get update 接下来,我们安装Git (一个版本控制系统)和curl, RVM的安装和使用需要使用到它们,还有build-essential用来编译 Ruby。为了安装这三个包,我们执行: sudo apt-get install build-essential git-core curl 阅读全文
posted @ 2011-10-24 20:56 kelby 阅读(766) 评论(0) 推荐(0) 编辑
摘要: 废话不多说,点击下面的链接,下载安装。安装过程中的会让你选择一些选项,你可以认真看一下或者直接打勾! http://rubyforge.org/frs/download.php/74977/railsinstaller-2.0.0.exe 恭喜你!安装好rails了。 阅读全文
posted @ 2011-10-24 20:51 kelby 阅读(190) 评论(0) 推荐(0) 编辑