Skip to content

Instantly share code, notes, and snippets.

@jathayde
Created March 30, 2018 19:00
Show Gist options
  • Save jathayde/087e1c6bcfd2ba9ba946a9b71dde6949 to your computer and use it in GitHub Desktop.
Save jathayde/087e1c6bcfd2ba9ba946a9b71dde6949 to your computer and use it in GitHub Desktop.
$('#follow_lodge').html("<%= escape_javascript(render partial: 'shared/follow_lodge', locals: {@issueable => @followable}) %>");
<% 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 %>
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
class FollowsLodgesController < FollowsController
def followable
@followable ||= @issueable
end
end
<% 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