Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 授权给Ramaze中的另一个操作_Ruby_Ramaze - Fatal编程技术网

Ruby 授权给Ramaze中的另一个操作

Ruby 授权给Ramaze中的另一个操作,ruby,ramaze,Ruby,Ramaze,如果传递了id,我想从索引操作委托给Show操作。我似乎无法让它工作,我在这里做错了什么 require 'ramaze' require 'slim' class UsersController < Ramaze::Controller engine :slim def index(id=nil) if id render_full "/users/show/#{id}" #id was passed, "show" the i

如果传递了id,我想从索引操作委托给Show操作。我似乎无法让它工作,我在这里做错了什么

require 'ramaze'
require 'slim'

class UsersController < Ramaze::Controller
    engine :slim

    def index(id=nil)
        if id
            render_full "/users/show/#{id}" #id was passed, "show" the item
        end
        #alright just render the "index.slim" here...
    end

    def show(id)
        u=User[id] #ORM stuff...
    end
end

Ramaze.start
require'ramaze'
要求“苗条”
类UsersController
您必须调用
return render_full(…)
而不是
render_full()
,否则,无论是否指定了ID,它下面的代码都将被执行。

您可以调用
return show(ID)
而不是
render_full”/users/show/{ID}
对不起,
return render_full“/users/show/#{id}”如果id
不起作用。据我观察,从操作返回字符串是有效的(正如预期的那样),但如果您设置了视图引擎,则不会。我似乎遇到奇怪的错误。抱歉,也不起作用!请查看我对Yorick答案的评论。