2012-03-07 65 views
0

我有這個微博鏈接will_paginate,我試圖將<%= user.id %>添加到此base_link_url但user.id不起作用。有沒有一種方法,我可以添加user.id到這個沒有收到錯誤?Rails:如何將用戶標識添加到鏈接

鏈接

<%= will_paginate microposts, :renderer => CustomLinkRenderer, :base_link_url => "https://stackoverflow.com/users/<%= user.id %>", :page_links => false , :class =>"pagination" %>

對於那些有興趣誰在那裏我得到了這一點,就從這裏開始:

Issue with will_paginate page links

的錯誤

/Users/Brian/rails_projects/project/app/views/users/_microposts.html.erb:4: syntax error, unexpected '>' 
/Users/Brian/rails_projects/project/app/views/users/_microposts.html.erb:6: syntax error, unexpected keyword_class, expecting keyword_do or '{' or '(' 
..._buffer.safe_concat('<div class="EmptyContainer"><span class... 
...        ^
/Users/Brian/rails_projects/project/app/views/users/_microposts.html.erb:6: syntax error, unexpected '<' 
...('<div class="EmptyContainer"><span class=\'Empty\'>Add a th... 
...        ^
+1

你得到什麼錯誤? – rwilliams 2012-03-07 01:18:15

+0

@rwilliams您從以前的工作回覆:) – Kellogs 2012-03-07 01:28:03

+1

我取消刪除它。 – rwilliams 2012-03-07 01:31:12

回答

2

試試這個。我不認爲你正確地將user.id變量插入該語句中。

<%= will_paginate microposts, :renderer => CustomLinkRenderer, :base_link_url => "https://stackoverflow.com/users/#{user.id}", :page_links => false , :class =>"pagination" %> 
+0

工作就像一個魅力,我只是不確定如何插入user.id.謝謝 :) – Kellogs 2012-03-07 01:21:04