0

以下のようにlink_toを使いたいのですが、うまくいきません。それは何もしません:(

<% unless user == current_user %>
  <% if current_user.following?(user) %>
    <%= link_to sanitize('<i class="icon-remove icon-white"></i> ') + 'Un-Follow', user_follow_path(user.to_param, current_user.get_follow(user).id), :method => :delete, :remote => true, :class => 'btn' %>             
  <% else %>
    <%= link_to sanitize('<i class="icon-ok icon-white"></i> ') + 'Follow', user_follows_path(user.to_param), :remote => true, :class => 'btn btn-primary' %>             
  <% end %>
<% end %>

しかし、以下のようにbutton_toでコーディングすると、完全に機能します。なぜ???

<% unless user == current_user %>
  <% if current_user.following?(user) %>
    <%= button_to("Un-Follow #{user.username}", user_follow_path(user.to_param, current_user.get_follow(user).id), :method => :delete, :remote => true) %>
  <% else %>
    <%= button_to("Follow #{user.username}", user_follows_path(user.to_param), :remote => true) %>
  <% end %>
<% end %>
4

2 に答える 2

1
<% unless user == current_user %>
<% if current_user.following?(user) %>
<%= button_to("Un-Follow #{user.username}", user_follow_path(user.to_param, current_user.get_follow(user).id), :method => :delete, :remote => true, 
:class => 'btn btn-primary') %>
<% else %>
<%= button_to("Follow #{user.username}", user_follows_path(user.to_param), 
:remote => true, :class => 'btn btn-primary') %>
<% end %>
<% end %>

私はlink_to atmを検索します:)

[編集]

わかりました:)いくつかのフォローアクションをユーザーコントローラーに移動し、両方のlink_toに特定のルートを使用する必要があります。rubycas レイアウトを削除し、認証に単純なデバイスを使用します。シードはプロジェクト内にあります。

https://github.com/senayar/follower

于 2012-12-14T09:52:00.723 に答える
0
 <%= link_to(user_follow_path(user.to_param, current_user.get_follow(user).id), :method => :delete, :remote => true, :class => 'btn') do %>
   <i class="icon-remove icon-white"></i>
   'Un-Follow'
 <% end %>

上記を試してください。ブートストラップアイコンで動作します

于 2012-12-13T12:12:26.013 に答える