Sha256: 7a507be7ce3accbcdfa29edd4eee1420a767ee218fad1be70a8d2990e43269d1

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

module Conversations
  class ConversationsController < ::ApplicationController
    include ApplicationHelper

    def new
      @user = User.find(params[:user_id])
      @conversation = Conversation.new
      @conversation.messages.build
    end

    def create
      @user = User.find(params[:user_id])
      @conversation = Conversation.new params[:conversations_conversation]
      @conversation.user_conversations.build
      @conversation.user_conversations.first.user = @user
      @conversation.messages.build :body => params[:conversations_conversation][:messages_attributes]['0'][:body]
      @conversation.messages.first.user = @user
      if @conversation.save
        redirect_to user_conversation_path(@user, @user.user_conversations.last), notice: 'Conversation was successfully created.'
      else
        render action: "new"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conversations-0.0.1 app/controllers/conversations/conversations_controller.rb