%tbody
- @accounts.each do |account|
%tr
%td= link_to account['id'],show_path,{:id => account['id']}
%td= account['name']
%td= account['description']
%td= account['created']
以上只是haml文件的一个片段,在我的控制器中我有以下内容:
def show
# If a system account already exists in session, it was found from a search with the account id
# Otherwise, this is a new search for a system account by the given id
@account = session[:account]
if @account.nil?
Rails.logger.debug { "Querying for the account with id: #{params[:id]}" }
response = query_account(CGI.escape(params[:id]))
@account = JSON.parse(response.body)
end
end
路线(show_path)是 /system_accounts/:id
如果 id 为 23,我如何将参数 id 传递给控制器并链接 /system_accounts/23 例如:。