end
def new
- @ground_color = GroundColor.new params[:ground_color]
+ raise Pettanr::NotWork unless @author.working_panel
+ @panel = Panel.edit(@author.working_panel, @author)
+ @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
@ground_color.supply_default
- @panel = @author.working_panel
respond_to do |format|
format.html
end
def create
- @ground_color = GroundColor.new params[:ground_color]
- @ground_color.supply_default
+ raise Pettanr::NotWork unless @author.working_panel
@panel = Panel.edit(@author.working_panel, @author)
+
+ @ground_color = GroundColor.new
+ @ground_color.attributes = params[:ground_color]
@ground_color.overwrite @panel.id
respond_to do |format|
format.html { redirect_to @panel }
format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
else
- format.html { render action: "panels/new" }
- format.json { render json: @panel.errors, status: :unprocessable_entity }
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
+ format.html { render action: "new" }
+ format.json { render json: @ground_color.errors, status: :unprocessable_entity }
end
else
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
format.html { render action: "new" }
format.json { render json: @ground_color.errors, status: :unprocessable_entity }
end
format.html { redirect_to @ground_color }
format.json { head :ok }
else
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human)
format.html { render action: "edit" }
format.json { render json: @ground_color.errors, status: :unprocessable_entity }
end