Fixed saving user for new orders.

This commit is contained in:
Benjamin Meichsner 2013-01-26 16:24:45 +01:00
parent 44ef0a9807
commit 8b2b70f8bf
3 changed files with 3 additions and 4 deletions

View file

@ -60,6 +60,7 @@ class OrdersController < ApplicationController
# order_articles will be saved in Order.article_ids=()
def create
@order = Order.new(params[:order])
@order.created_by = current_user
if @order.save
flash[:notice] = "Die Bestellung wurde erstellt."
redirect_to @order

View file

@ -142,7 +142,8 @@ module ApplicationHelper
# offers a link for writing message to user
# checks for nil (useful for relations)
def link_to_user_message_if_valid(user)
user.nil? ? '??' : ( link_to user.nick, user_message_path(user), :title => 'Nachricht schreiben' )
user.nil? ? '??' : link_to(user.nick, new_message_path('message[mail_to]' => user.id),
:title => 'Nachricht schreiben')
end
def bootstrap_flash

View file

@ -19,9 +19,6 @@ class Order < ActiveRecord::Base
validate :starts_before_ends, :include_articles
# Callbacks
before_create do |order|
order.created_by = User.current_user
end
after_update :update_price_of_group_orders
after_save :save_order_articles