Created
March 30, 2018 19:00
-
-
Save jathayde/087e1c6bcfd2ba9ba946a9b71dde6949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#follow_lodge').html("<%= escape_javascript(render partial: 'shared/follow_lodge', locals: {@issueable => @followable}) %>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if current_user.following?(@issueable) %> | |
<%= button_to("Un-Follow #{@issueable.combined}", | |
lodge_follows_path(@issueable.to_param, current_user.follows?(@issueable)), | |
method: :delete, | |
remote: true) %> | |
<% else %> | |
<%= button_to("Follow #{@issueable.combined}", | |
lodge_follows_path(@issueable.to_param), | |
remote: true) %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FollowsController < ApplicationController | |
def create | |
current_user.follow(followable) | |
respond_to :js | |
end | |
def destroy | |
current_user.stop_following(followable) | |
respond_to :js | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FollowsLodgesController < FollowsController | |
def followable | |
@followable ||= @issueable | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if user_signed_in? %> | |
<div id="follow_lodge"> | |
<!-- does not work when uncommented, renders code as text inline --> | |
<%#= render 'follows_lodges/create.js' %> | |
<!-- does work, but then fails on url gen, which is seperate issue --> | |
<%= render partial: 'shared/follow_lodge', locals: {@issueable => @followable} %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment