小编ibu*_*uck的帖子

Rails 3.0.3资源路由没有索引映射?

我正在尝试为我的楼宇控制器使用一个非常简单的资源路径.

resource :buildings
Run Code Online (Sandbox Code Playgroud)

这导致以下映射

buildings POST   /buildings(.:format) {:controller=>"buildings", :action=>"create"}
         new_buildings GET    /buildings/new(.:format)          {:controller=>"buildings", :action=>"new"}
        edit_buildings GET    /buildings/edit(.:format)         {:controller=>"buildings", :action=>"edit"}
                       GET    /buildings(.:format)              {:controller=>"buildings", :action=>"show"}
                       PUT    /buildings(.:format)              {:controller=>"buildings", :action=>"update"}
                       DELETE /buildings(.:format)              {:controller=>"buildings", :action=>"destroy"}
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么没有为默认/建筑物GET请求映射索引操作?我正在使用rails 3.0.3

routing ruby-on-rails

24
推荐指数
1
解决办法
5773
查看次数

grails应用程序根上下文

我有一个带有"/ testapp"上下文的测试grails应用程序设置.当我在我的gsp中添加一个链接时,引用/它不会转到我的grails.app.context的根目录,而是转到我的grails.serverURL属性的根目录.

例如,给出与href"/css/main.css"的链接

我希望这个链接实际上看起来是localhost:8080/testapp/css/main.css而不是localhost:8080/css/main.css

有没有办法可以从grails.app.context和grails.serverURL开始引用/开始?

grails groovy

7
推荐指数
3
解决办法
1万
查看次数

grails覆盖重定向控制器方法

我试图覆盖默认的控制器重定向方法,似乎无法使下面的代码工作.

我创建了一个插件,我正在尝试使用"doWithDynamicMethods"来替换重定向.

def doWithDynamicMethods = {ctx ->
   application.controllerClasses.each() { controllerClass ->
      replaceRedirectMethod(controllerClass)
   }
}

void replaceRedirectMethod(controllerClass) {
   def oldRedirect = controllerClass.metaClass.pickMethod("redirect", [Map] as Class[])
   controllerClass.metaClass.redirect = { Map args, Map params ->
      // never seems to get here    
   }
}
Run Code Online (Sandbox Code Playgroud)

我有签名错误还是我错过了什么?我这样做的原因是我想改变重定向的uri如果满足某个条件但是使用logging/print语句我看到它在应用程序启动/编译时会出现在"replaceRedirectMethod"中但是它没有应用程序启动后,通过控制器进行重定向时,请进入此处.

grails grails-plugin

5
推荐指数
1
解决办法
1166
查看次数

标签 统计

grails ×2

grails-plugin ×1

groovy ×1

routing ×1

ruby-on-rails ×1