Rails newbie here. I'm looking to learn a little bit about jQuery so I figured I'd try to switch between my views using AJAX. I'm really looking forward to insights in how to do this!
Right now on my user's dash I have a link to their 'likes' page, it requires a full reload to see the 'show_likes' views, how would I refresh the div id="content" with the new view 'show_likes' ??
Thanks!
views/pages/home.html.erb
<div id="left">
<div id="dash-statistics">
<a href="<%= likes_user_path(@user) %>">
<div id="likes" class="stat">Likes
<%= @user.likes.count %>
</div>
</a>
</div>
</div>
<div id="right">
<div id="content">
</div>
</div>
UsersController
def home
@title = "Home"
if user_signed_in?
@user = current_user
@post = current_user.posts.build
@collections = @user.posts.map(&:collections).flatten.uniq
@recommended_posts_count = @user.posts.where(:is_recommended => true).count
@feed_items = @user.feed.paginate(:per_page => "10", :page => params[:page])
end
end
def likes
@title = "Likes"
@user = User.find(params[:id])
@like_stuff = @user.likes.paginate(:page => params[:page])
render 'show_likes'
end