0

ポップアップを作成する link_to があります。一部のページでは機能しますが、他のページでクリックすると間違った URI に移動します。アプリのアーキテクチャに問題がありますか? すべてのリンクをルーティングしたい

http://localhost:3000/microposts/361/into_it.

SHARED/_feed_item.html.erb---このコード行は適切にルーティングされます:

<%= link_to "#{feed_item.votes_for} Into it!", into_it_micropost_path(feed_item.id), :onclick => "javascript:window.open('microposts/#{feed_item.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{feed_item.id}", remote: true %>

USERS/_vote_feed_item.html.erb--- いいねのページでは、

http://localhost:3000/users/1/microposts/361/into_it

<%= link_to "#{vote_feed_item.votes_for} Into it!", into_it_micropost_path(vote_feed_item.id), :onclick => "javascript:window.open('microposts/#{vote_feed_item.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{vote_feed_item.id}", remote: true %>

MICROPOSTS/_micropost.html.erb---プロフィールページでのルーティング先

http://localhost:3000/users/microposts/361/into_it

<%= link_to "#{micropost.votes_for} Into it!", into_it_micropost_path(micropost.id), :onclick => "javascript:window.open('microposts/#{micropost.id}/into_it','popup','width=350,height=300,top=315,left=200');", id: "feeditemlikes_#{micropost.id}", remote: true %>

実際には、javascript ポップアップ コードに問題があるようですが、何かヒントはありますか?

4

1 に答える 1

0

私があなたのことを正しく理解しているなら、あなたはいつも次のサイトにリンクしたいと思っています。http://localhost:3000/microposts/361/into_it

次に、パスの先頭にスラッシュを追加する必要があります。

"javascript:window.open('/microposts/#{micropost.id}/into_it', ..."

または、次のような Rails パス ヘルパーを使用することをお勧めします。

"javascript:window.open(#{into_it_path(micropost)}, ..."
于 2013-01-14T18:00:08.647 に答える