def create_or_update_record(params)
hsh = ActiveSupport::JSON.decode(params[:data])
hsh.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]
@record ||= data_class.find(:first, :conditions => {data_class.primary_key => hsh.delete(data_class.primary_key)}) # only pick up the record specified in the params if it was not provided in the configuration
success = true
@record = data_class.new if @record.nil?
hsh.each_pair do |k,v|
begin
@record.send("#{k}=",v)
rescue StandardError => exc
flash :error => exc.message
success = false
break
end
end
# Corey
if session[:netzke_user_id]
user = User.find(session[:netzke_user_id])
@record.user_id = user.id
# did we have complete success?
success && @record.save
else
flash :error => "您必須先登錄才能异动资料!"
success = false
end
end