简体   繁体   中英

Why doesn't `posts_path` work in `rails console`?

Why does link_to 'Back', posts_path work in ERB but posts_path doesn't work in the console?

$ rails console
irb(main):005:0> posts_path
NameError: undefined local variable or method `posts_path' for main:Object

You need to add context of app in console.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM