Strong parameters for Conversation

This commit is contained in:
James Fleming 2013-06-27 18:09:16 +02:00 committed by Jonne Haß
parent 509a407286
commit b86b409f7d
2 changed files with 7 additions and 5 deletions

View file

@ -34,13 +34,14 @@ class ConversationsController < ApplicationController
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map(&:person_id) person_ids = Contact.where(:id => params[:contact_ids].split(',')).map(&:person_id)
end end
params[:conversation][:participant_ids] = [*person_ids] | [current_user.person_id] @conversation = Conversation.new
params[:conversation][:author] = current_user.person @conversation.subject = params[:conversation][:subject]
message_text = params[:conversation].delete(:text) @conversation.participant_ids = [*person_ids] | [current_user.person_id]
params[:conversation][:messages_attributes] = [ {:author => current_user.person, :text => message_text }] @conversation.author = current_user.person
message_text = params[:conversation][:text]
@conversation.messages_attributes = [ {:author => current_user.person, :text => message_text }]
@response = {} @response = {}
@conversation = Conversation.new(params[:conversation])
if person_ids.present? && @conversation.save if person_ids.present? && @conversation.save
Postzord::Dispatcher.build(current_user, @conversation).post Postzord::Dispatcher.build(current_user, @conversation).post
@response[:success] = true @response[:success] = true

View file

@ -1,6 +1,7 @@
class Conversation < ActiveRecord::Base class Conversation < ActiveRecord::Base
include Diaspora::Federated::Base include Diaspora::Federated::Base
include Diaspora::Guid include Diaspora::Guid
include ActiveModel::ForbiddenAttributesProtection
xml_attr :subject xml_attr :subject
xml_attr :created_at xml_attr :created_at