我正在将一个应用程序从 rails 2 转换为 rails 3,有人可以帮我解决这个小代码。link_to不工作,有人能告诉我如何正确使用 link_to 而不是 rails 3.1 中的 link_to_remote 吗?导轨 2 代码
<%= link_to_remote package_item.getId(),
:url => { :controller => 'cmn/popup',
:action => "show_popup",
:frame_url => admin_url(
:ctrl => controller,
:app_action => 'package.item.edit',
:id => package_item.getId().to_s,
:remote => true
),
:frame_width => '570px',
:frame_height => '355px'
}
%>
Rails 3.1 代码
<%= link_to package_item.getId(),
:url => { :controller => 'cmn/popup',
:action => "show_popup",
:frame_url => admin_url(
:ctrl => controller,
:app_action => 'package.item.edit',
:id => package_item.getId().to_s
),
:frame_width => '570px',
:frame_height => '355px',
:remote => true
}
%>
我将所有.rjs
文件替换为.js.erb
. 这是我在 Rails 3 中获得的 URL:
<a href="/common/login/en/sentry?url%5Baction%5D=show_popup&url%5Bcontroller%5D=cmn%2Fpopup&url%5Bframe_height%5D=355px&url%5Bframe_url%5D=%2Fcommon%2Flogin%2Fen%2Fsentry%3Fapp_action%3Dpackage.item.edit%26id%3D3%26remote%3Dtrue&url%5Bframe_width%5D=570px&url%5Bremote%5D=true">3</a>
这是在 Rails 2 中:
<a href="#" onclick="new Ajax.Request('/cmn/popup/show_popup?frame_height=355px&frame_url=%2Fcmn%2Fcmn%2Findex%2F2%3Fapp_action%3Dpackage.item.edit%26amp%3Bbrand%3Dsentry%26amp%3Blanguage%3Den&frame_width=570px', {asynchronous:true, evalScripts:true}); return false;">2</a>
我的控制器
def show_popup
@content_data = {}
@content_data.merge!(params)
render(:template => 'cmn/popup/show_popup', :nolayout => 1)
end