Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Like/Unlike Button -->
- <% if current_user %>
- <!-- If the user is signed in, allow them to vote -->
- <div class="votes">
- <% if (current_user.liked? resource) %>
- <!-- Unlike -->
- <%= render(:partial => 'unlike', :locals => {:resource => resource})%>
- <% else %>
- <!-- Like -->
- <%= render(:partial => 'like', :locals => {:resource => resource})%>
- <% end %>
- </div>
- <% else %>
- <!-- If the user is not signed in, send them to Twitter -->
- <%= link_to "/auth/twitter" do %>
- <button class="ui basic compact icon right floated button" data-tooltip="You need to sign in before saving this link." data-variation="basic" data-position="top right">
- <i class="heart icon" style="color: #EDB0B1"></i> <%= resource.get_likes.size %>
- </button>
- <% end %>
- <% end %>
- <%= link_to like_resource_path(resource), method: :get, remote: true, class: 'like_resource' do %>
- <button class="ui basic compact icon right floated button vote_count">
- <i class="heart icon" style="color: #F1F1F1"></i> <%= resource.get_likes.size %>
- </button>
- get 'auth/twitter/callback', to: 'sessions#create'
- class SessionsController < ApplicationController
- def create
- auth = request.env["omniauth.auth"]
- user = User.from_omniauth(auth)
- session[:user_id] = user.id
- redirect_to user, :notice => "Signed in!"
- end
- def destroy
- session[:user_id] = nil
- redirect_to root_url, :notice => "Signed out!"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement