刷新当前页面的操作
我想在 Rails 控制器中创建一个操作,该操作在数据库中执行某些操作,然后刷新当前页面。
示例:
控制器:A
视图:A,B。
控制器A如下:
def action1
somethingToTheDB
end
视图A如下:
-html-
-body--link to action 1--/body-
-/html-
视图B如下
-html-
-body--link to action 1--/body-
-/html-
如果我从视图AI进入操作1想要刷新视图A,如果我来自视图2我想要刷新视图2是否可以在链接中传递参数来指示必须呈现的视图?
谢谢
I want to create an action in a Rails controller that does something in the db and then just refreshes the current page.
Example:
Controller: A
Views: A, B.
controller A is the following:
def action1
somethingToTheDB
end
view A is the following:
-html-
-body--link to action 1--/body-
-/html-
view B is the following
-html-
-body--link to action 1--/body-
-/html-
If I come to action 1 from view A I want to refresh view A, if I come from view 2 I want to refresh view 2. Is that possible without passing a parameter in the link to indicate the view that must be rendered?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定是否明白您的问题,但您不能这样做:
如果您出于某种原因需要访问
action_1
中的controller_name
和action_name
:aktion
和kontroller
没有拼写错误。你必须这样写,否则会发生冲突。action_name
和controller_name
是变量。像这样写它们。它看起来像这样(取决于您的
refresh_path
、您当前的控制器和当前的操作):然后在您的控制器中:
Not sure to catch your question but can't you just do:
If you need to access your
controller_name
andaction_name
in youraction_1
for whatever reason:aktion
andkontroller
aren't typo. You have to write them like that, otherwise, it will clash.action_name
andcontroller_name
are variables. Write them like that.It will look like something like that (depending on what's your
refresh_path
, your current controller and your current action):Then in your controller: