Skip to content

Instantly share code, notes, and snippets.

@bntzio
Created April 3, 2015 17:37
Show Gist options
  • Save bntzio/8b91ece1479e8dffffb5 to your computer and use it in GitHub Desktop.
Save bntzio/8b91ece1479e8dffffb5 to your computer and use it in GitHub Desktop.
icnoming controller
class IncomingController < ApplicationController
# http://stackoverflow.com/questions/1177863/how-do-i-ignore-the-authenticity-token-for-specific-actions-in-rails
skip_before_action :verify_authenticity_token, only: [:create]
def create
@user = current_user
@topic = Topic.create(title: params[:subject], user_id: @user.id)
@url = params["body-plain"]
@bookmark = Bookmark.create(url: @url, topic_id: @topic.id)
# @user = User.find_by(email: params[:sender])
# @topic = Topic.find_by(title: params[:subject], user_id: @user_id)
# @url = "http://#{params["body-plain"]}"
# @user = User.create(email: params[:sender], password: "#{params[:title]}_bookmarkthis") if @user.nil?
# @topic = Topic.create(title: params[:subject], user_id: @user_id) if @topic.nil?
# @bookmark = Bookmark.create(url: @url, topic_id: @topic.id)
# puts "#{@user}, #{@topic}, #{@url}"
# Assuming all went well.
head 200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment