为什么在Rails控制台中无法使用`posts_path`?

3
为什么在ERB中link_to 'Back', posts_path可以工作,但是在控制台中posts_path不能工作?
$ rails console
irb(main):005:0> posts_path
NameError: undefined local variable or method `posts_path' for main:Object
1个回答

6

您需要在控制台中添加app的上下文。

app.posts_path
app.get app.posts_path
app.response
app.response.body

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接