Tag: ruby内饰

Rails使用什么Ruby技术来使我的控制器方法呈现视图?

只是好奇是否有人知道在Rails框架中使用什么Ruby技术来完成以下操作。 如果我不在Rails控制器上编写index方法,如果URL匹配该路由,Rails仍将呈现索引视图文件。 这是有道理的,因为我的控制器inheritance自父类,父类必须有自己的index方法。 但是,如果我确实定义了一个index方法,并且只告诉它设置一个实例变量,它仍会呈现相应的视图。 例如: def index @weasels = Weasel.all # If I omit this line, Rails renders the index anyway. # If this behavior is defined in the parent class’s index method, # it seems that by overriding the method, my index wouldn’t do it. # I’m not explicitly calling super to get the […]