130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/acts_as_archive_controller.rb', line 130
def create
record = self.class.content_class_name.constantize.new(params[self.class.singular_name.to_sym])
instance_variable_set("@#{self.class.singular_name}", record)
record.parent = @parent_node
respond_to do |format|
if @commit_type == 'preview' && record.valid?
format.html { render :template => 'admin/shared/create_preview', :locals => { :object => record }, :layout => 'admin/admin_preview' }
format.xml { render :xml => record, :status => :created, :location => record }
elsif @commit_type == 'save' && record.save
format.html { render :template => 'admin/shared/create' }
format.xml { render :xml => record, :status => :created, :location => record }
else
format.html { render :template => 'admin/shared/new', :locals => { :object => record }, :status => :unprocessable_entity }
format.xml { render :xml => record.errors, :status => :unprocessable_entity }
end
end
end
|