Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy Ajax won't reflect on show but index?
    primarykey
    data
    text
    <p>Now if I press follow on index page, the button changes 'follow' to 'un-follow' right away. But, at show page, nothing won't happen. How can I fix this??</p> <p>views/users/show.html.erb</p> <pre><code>&lt;h1&gt;Users#show&lt;/h1&gt; &lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt; &lt;p&gt; &lt;b&gt;User:&lt;/b&gt; &lt;%= @user.user_profile.user_id %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Language:&lt;/b&gt; &lt;%= @user.user_profile.language_id %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Country:&lt;/b&gt; &lt;%= @user.user_profile.country_id %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Prefecture:&lt;/b&gt; &lt;%= @user.user_profile.prefecture_id %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Gender:&lt;/b&gt; &lt;%= @user.user_profile.gender_id %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Nickname:&lt;/b&gt; &lt;%= @user.user_profile.nickname %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Introduction:&lt;/b&gt; &lt;%= @user.user_profile.introduction %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Picture url:&lt;/b&gt; &lt;%= @user.user_profile.picture_url %&gt; &lt;/p&gt; &lt;p&gt; &lt;b&gt;Tag List:&lt;/b&gt; &lt;% @user.tags.each do |tag| %&gt; &lt;span&gt;&lt;%= link_to tag.name, {:action=&gt;'index', :tag=&gt;tag.name} %&gt;&lt;/span&gt; &lt;% end %&gt; &lt;/p&gt; &lt;% if user_signed_in? %&gt; &lt;div id="follow_user" data-user-id="&lt;%= @user.id %&gt;"&gt; &lt;%= render :partial =&gt; "follow_user", :locals =&gt; {:user =&gt; @user} %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>follows_controller.rb</p> <pre><code>class FollowsController &lt; ApplicationController def create @user = User.find(params[:user_id]) current_user.follow(@user) respond_to do |format| format.js {render :action=&gt;"create.js"} end end def destroy @user = User.find(params[:user_id]) current_user.stop_following(@user) respond_to do |format| format.js {render :action=&gt;"destroy.js"} end end end </code></pre> <p>views/users/_follow_user.html.erb</p> <pre><code>&lt;% unless user == current_user %&gt; &lt;% if current_user.following?(user) %&gt; &lt;%= button_to("Un-Follow", user_follow_path(user.to_param, current_user.get_follow(user).id), :method =&gt; :delete, :remote =&gt; true, :class =&gt; 'btn') %&gt; &lt;% else %&gt; &lt;%= button_to("Follow", user_follows_path(user.to_param), :remote =&gt; true, :class =&gt; 'btn btn-primary') %&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>views/follows/create.js.erb</p> <pre><code>$('.follow_user[data-user-id="&lt;%=@user.id%&gt;"]').html('&lt;%= escape_javascript(render :partial =&gt; "follow_user", :locals =&gt; {:user =&gt; @user}) %&gt;'); #jQuery </code></pre> <p>views/follows/destroy.js.erb</p> <pre><code>$('.follow_user[data-user-id="&lt;%=@user.id%&gt;"]').html('&lt;%= escape_javascript(render :partial =&gt; "follow_user", :locals =&gt; {:user =&gt; @user}) %&gt;'); #jQuery </code></pre> <p>views/users/index.html.erb</p> <pre><code>&lt;%- model_class = User.new.class -%&gt; &lt;div class="page-header"&gt; &lt;h1&gt;&lt;%=t '.title', :default =&gt; model_class.model_name.human.pluralize %&gt;&lt;/h1&gt; &lt;/div&gt; &lt;% @from %&gt; &lt;h3&gt;tag cloud&lt;/h3&gt; &lt;% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %&gt; &lt;%= link_to tag.name, {:action=&gt;'index', :tag=&gt;tag.name}, :class =&gt; css_class%&gt; &lt;% end %&gt; &lt;%= paginate @users %&gt; &lt;table class="table table-condensed"&gt; &lt;thead&gt;&lt;/thead&gt; &lt;tbody&gt; &lt;% @users.each do |user| %&gt; &lt;div class="memberListBox"&gt; &lt;div class="memberList"&gt; &lt;p class="name"&gt;&lt;span&gt;&lt;%= user.user_profile.nickname %&gt;&lt;/span&gt;(&lt;%= user.user_profile.age %&gt;)&lt;/p&gt; &lt;p class="size"&gt;&lt;%= user.username %&gt;&lt;/p&gt; &lt;p class="img"&gt; &lt;% if user.user_profile.user_avatar? %&gt; &lt;%= image_tag(user.user_profile.user_avatar.url(:thumb),:height =&gt; 100, :width =&gt; 100, :class =&gt; 'img-polaroid' ) %&gt; &lt;% else %&gt; &lt;%= image_tag('nophoto.gif',:height =&gt; 100, :width =&gt; 100, :class =&gt; 'img-polaroid' ) %&gt; &lt;% end %&gt; &lt;/p&gt; &lt;div class="introduction"&gt; &lt;%= user.user_profile.introduction %&gt; &lt;/div&gt; &lt;% if user_signed_in? &amp;&amp; current_user!=user %&gt; &lt;div class="follow_user" data-user-id="&lt;%= user.id %&gt;"&gt; &lt;%= render :partial =&gt; "follow_user", :locals =&gt; {:user =&gt; user} %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;%= link_to sanitize('&lt;i class="icon-pencil icon-white"&gt;&lt;/i&gt; ') + 'Message', new_messages_path(user.username), :class =&gt; 'btn btn-primary' %&gt; &lt;%= link_to sanitize('&lt;i class="icon-user icon-white"&gt;&lt;/i&gt; ') + 'Profile', show_user_path(:username =&gt; user.username, :breadcrumb =&gt; @from), :class =&gt; 'btn btn-info' %&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload