为什么 link_to 没有带我去我想要的地方?

发布于 2024-08-14 02:16:54 字数 1403 浏览 14 评论 0原文

我有一个模型“资产”,并且在显示页面上有:

{ :controller 'looks', :action => 'whatever' } %>

“外观”控制器和“无论”操作都存在。

现在,当我进入第二个资产的显示页面并单击测试链接时,我收到此错误:

处理 AssetsController#2(适用于 127.0.0.1,2009-12-03 17:09:57)[POST] 参数:{"authenticity_token"=>"aLGRq+ZVulWbwC09m1dy7Mj9b9AgSJqkwiS99SLk6uk="} 用户负载 (0.6ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1

ActionController::UnknownAction(没有操作响应2。操作:创建、销毁、索引、新建、接收和显示): /usr/lib/ruby/gems/1.8/gems/chriseppstein-compass-0.8.17/lib/compass/app_integration/rails/action_controller.rb:7:在 process' haml (2.3.0) lib/sass/plugin/rack.rb:44:in调用' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:在 service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in运行' /usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in开始' /usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in开始' /usr/lib/ruby/1.8/webrick/server.rb:92:in each' /usr/lib/ruby/1.8/webrick/server.rb:92:in开始' /usr/lib/ruby/1.8/webrick/server.rb:23:在 start' /usr/lib/ruby/1.8/webrick/server.rb:82:in开始'

渲染救援/布局(not_found)

所以显然它引导我执行一个名为 asset_id 的操作,该操作是我来自其节目的。如果有帮助,我正在使用 authlogic 和 compass gem。我将不胜感激任何帮助。

I have a model 'Asset' and, on the show page, I have this:

{ :controller 'looks', :action => 'whatever' } %>

The 'looks' controller and 'whatever' action both exist.

Now when I go the the show page for the second Asset and click the test link I get this error:

Processing AssetsController#2 (for 127.0.0.1 at 2009-12-03 17:09:57) [POST]
Parameters: {"authenticity_token"=>"aLGRq+ZVulWbwC09m1dy7Mj9b9AgSJqkwiS99SLk6uk="}
User Load (0.6ms) SELECT * FROM "users" WHERE ("users"."id" = '1') LIMIT 1

ActionController::UnknownAction (No action responded to 2. Actions: create, destroy, index, new, receive, and show):
/usr/lib/ruby/gems/1.8/gems/chriseppstein-compass-0.8.17/lib/compass/app_integration/rails/action_controller.rb:7:in process'
haml (2.3.0) lib/sass/plugin/rack.rb:44:in
call'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in
run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in
start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in
start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in
start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in
start'

Rendering rescues/layout (not_found)

So apparently it's directing me to an action that's named whatever asset_id whose show I came from. If it helps, I'm using the authlogic and compass gems. I'd appreciate any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪花飘飘的天空 2024-08-21 02:16:54

这是您应用程序中的确切代码吗?对于初学者来说,您缺少 =>;介于:控制器和“外观”之间。

尝试

{ :controller => 'looks', :action => 'whatever' } %>

Is that the exact code from your app? For starters, you are missing a => between :controller and 'looks'.

try

{ :controller => 'looks', :action => 'whatever' } %>

蓝天 2024-08-21 02:16:54

除了上面提到的 dl 之外,您还使用了 link_to_remote,它将使用操作结果更新页面上的 div。您可能打算切换到 link_to,因为您建议您期望去某个地方。

否则,如果您想要 ajax 调用,您应该向 link_to_remote 调用添加一个参数,如下所示:

<%= link_to_remote 'test',
                   :update => "some-div-id", 
                   :url => { :controller => 'looks', :action => 'whatever' } %>

In addition to what dl mentioned above, you are using link_to_remote, which is going to be updating a div on your page with the results of the action. You may mean to switch to link_to, since you suggest you expect to go somewhere.

Otherwise, if you want an ajax call, you should add a parameter to the link_to_remote call as follows:

<%= link_to_remote 'test',
                   :update => "some-div-id", 
                   :url => { :controller => 'looks', :action => 'whatever' } %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文