彼得,我很高興爲您解決問題。
對於簡單的視圖助手,它很容易
> app.helper.link_to 'root', app.root_path
# <a href = ....> # as expected
但是您的具體情況不是那麼容易的,需要的form_for和view_context
然後一個控制器實例工作。
# Get a controller instance at first. Must do it.
# Without this step `app.controller` is nil
> app.get app.root_path
# Use an instance variable but not variable!
> @user = User.last
# Get the view
# Note you need to take the trouble to define url manually
# because console can only reach path through app instance
> app.controller.view_context.form_for(@user, url: app.user_path(@user)){|f| f.input :name}
# Job done
彼得,歡呼! :) –