Method: SubjectsController#update
- Defined in:
- app/controllers/subjects_controller.rb
#update ⇒ Object
PUT /subjects/1 PUT /subjects/1.json
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/controllers/subjects_controller.rb', line 147 def update if @work @subject = @work.subjects.find(params[:id]) else @subject.assign_attributes(params[:subject]) end classification = Classification.find(@subject.classification_id) if @subject.classification_id.present? subject_heading_type = SubjectHeadingType.find(@subject.subject_heading_type_id) if @subject.subject_heading_type_id.present? respond_to do |format| if @subject.save subject_heading_types = [] subject_heading_types << subject_heading_type if subject_heading_type @subject.subject_heading_types = subject_heading_types format.html { redirect_to @subject, :notice => t('controller.successfully_updated', :model => t('activerecord.models.subject')) } format.json { head :no_content } else @classification = classification @subject_heading_type = subject_heading_type format.html { render :action => "edit" } format.json { render :json => @subject.errors, :status => :unprocessable_entity } end end end |