-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG::InternalError: ERROR: constraint 21715 is not a foreign key constraint #300
Comments
After this happens, does the conversation exist in the |
No the conversation does not get inserted into the table. |
It's hard to diagnose the problem without seeing more of the code. Can you post your controller method that is calling the |
One of my previous developers wrote this, but I think it's pretty standard (based off of a tutorial probably). class ConversationsController < ApplicationController
before_filter :require_login
# load_and_authorize_resource
helper_method :mailbox, :conversation
def index
@conversations ||= current_user.mailbox.inbox.all
end
def create
recipient_emails = conversation_params(:recipients).split(',')
recipients = User.where(email: recipient_emails).all
conversation = current_user.send_message(recipients, *conversation_params(:body, :subject)).conversation
respond_to do |format|
if conversation.save
format.html { redirect_to redirect_to conversation_path(conversation), flash: { success: 'Message has sent successfully.' } }
format.js
else
format.html { render :new }
format.js { render json: { success: false } }
end
end
end
def reply
current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
redirect_to conversation_path(conversation)
end
def trashbin
@trash ||= current_user.mailbox.trash.all
end
def trash
conversation.move_to_trash(current_user)
redirect_to :conversations
end
def untrash
conversation.untrash(current_user)
redirect_to :back
end
def empty_trash
current_user.mailbox.trash.each do |conversation|
conversation.receipts_for(current_user).update_all(deleted: true)
end
redirect_to :conversations
end
private
def mailbox
@mailbox ||= current_user.mailbox
end
def conversation
@conversation ||= mailbox.conversations.find(params[:id])
end
def conversation_params(*keys)
fetch_params(:conversation, *keys)
end
def message_params(*keys)
fetch_params(:message, *keys)
end
def fetch_params(key, *subkeys)
params[key].instance_eval do
case subkeys.size
when 0 then self
when 1 then self[subkeys.first]
else subkeys.map{|k| self[k] }
end
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting a fatal error when I try to send messages in my production environment. It works fine in development and on my staging box (mirrors my production environment). I can't seem to get it working no matter what I try.
Here is the error from
log/production.log
The text was updated successfully, but these errors were encountered: