link_to 到一个页面,但控制器来自 Rails 中的另一个页面
我在堆栈上看到了一些类似的问题,但我不认为这是重复的,因为我得到的每个答案都特定于一个潜在问题。
我会保持简单。我想知道如何单击链接,让它将用户带到一个页面,但从另一个页面执行 def。这是一个网络爬虫的 Rails 应用程序,我认为它很简单,但对我来说却很糟糕。
目前我有:
<td><%= link_to 'Crawl!', crawl_path :controller => :crawl, :action => :crawl %>
这会在爬虫运行完成后将用户带到爬虫的索引页面。 我想做的是将它们重定向到不同的页面。即 jobs_path,它显示爬虫站点和状态的列表(这工作正常,我只是想将其包含在内以实现相关性)。如果我这样尝试:
<td><%= link_to 'Crawl!', jobs_path, :controller => :crawl, :action => :crawl %>
用户被定向到作业页面,但爬虫脚本从未运行,因此作业列表从未更新。根据记录,每个作业只是一个 url 和它所在的深度。
这只是一个语法错误还是我离谱了?
任何帮助表示赞赏。
I've seen some similar questions on stack but I don't think this is a duplicate as each answer I've gottent has been specific to one underlying problem.
Ill keep it simple. I'd like to know how to click a link, have it take the user to one page but execute a def from another. This is in a rails application of a web crawler and Its something I thought would be quite simple but turned nasty on me.
At the moment I have:
<td><%= link_to 'Crawl!', crawl_path :controller => :crawl, :action => :crawl %>
This takes the user to the crawler's index page after its done running.
What I would like to do is redirect them to a different page. Namely jobs_path which shows a list of the crawlers sites and status (this is working fine, I just want to included it for relevance). If I try it like this:
<td><%= link_to 'Crawl!', jobs_path, :controller => :crawl, :action => :crawl %>
The user is directed to the jobs page but the crawler script never ran and thus the jobs list was never update. For the record, each job is just a url and the depth that it lies at.
Is this just a syntactical error or am I miles off the mark?
Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将
crawl#crawl
中的redirect_to
设置为了什么?也许将其设置为在完成后重定向到jobs_path
?What have you set your
redirect_to
incrawl#crawl
as? Perhaps set it to redirect tojobs_path
upon completion?