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
分享到:
相关推荐
AppWizard creates one document type and one view: 3DSLoaderDoc.h, 3DSLoaderDoc.cpp - the document These files contain your CMy3DSLoaderDoc class. Edit these files to add your special document data ...
Microsoft Developer Studio reads and updates this file. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" to indicate parts of the ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC40DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
AppWizard creates one document type and one view: MyPenDoc.h, MyPenDoc.cpp - the document These files contain your CMyPenDoc class. Edit these files to add your special document data and to ...
AppWizard creates one document type and one view: DrawDemoDoc.h, DrawDemoDoc.cpp - the document These files contain your CDrawDemoDoc class. Edit these files to add your special document data and ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
AppWizard creates one document type and one view: firDoc.h, firDoc.cpp - the document These files contain your CFirDoc class. Edit these files to add your special document data and to implement ...
AppWizard creates one document type and one view: MyDrawDoc.h, MyDrawDoc.cpp - the document These files contain your CMyDrawDoc class. Edit these files to add your special document data and to ...
AppWizard creates one document type and one view: CellDoc.h, CellDoc.cpp - the document These files contain your CCellDoc class. Edit these files to add your special document data and to implement ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC40DEU.DLL contains resources ...
AppWizard creates one document type and one view: MouseDemoDoc.h, MouseDemoDoc.cpp - the document These files contain your CMouseDemoDoc class. Edit these files to add your special document data ...
AppWizard creates one document type and one view: xieyuyingDoc.h, xieyuyingDoc.cpp - the document These files contain your CXieyuyingDoc class. Edit these files to add your special document ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. For example, MFC42DEU.DLL contains resources ...