Skip to content

Instantly share code, notes, and snippets.

View maxgronlund's full-sized avatar
🎯
Study Microservices

Synthmax maxgronlund

🎯
Study Microservices
View GitHub Profile
@maxgronlund
maxgronlund / follo_topic.ex
Created May 7, 2016 19:49
Ajax follow button
defmodule MusicTester.FollowTopic do
use MusicTester.Web, :model
schema "follow_topics" do
belongs_to :user, MusicTester.User
belongs_to :topic, MusicTester.Topic
timestamps
end
@maxgronlund
maxgronlund / console output
Last active May 1, 2016 14:02
The controller
Compiled web/channels/room_channel.ex
[info] POST /api/v1/like_posts
[debug] Processing by MusicTester.LikePostController.create/2
Parameters: %{"like_post" => "{ post_id: 15, user_id: 1}"}
Pipelines: [:api]
"{ post_id: 15, user_id: 1}"
[info] Sent 500 in 7ms
[error] #PID<0.898.0> running MusicTester.Endpoint terminated
Server: localhost:4000 (http)
$(".like-post").click(function() {
let csrf = document.querySelector("meta[name=csrf]").content;
let params = $(this).attr('value')
$.ajax({
url: "/like_posts",
type: "POST",
params: {like_post: params},
data: {
like_post: params