+ else
+ render :action => 'edit'
+ end
+ else
+ @diary_entry = DiaryEntry.new(:language_code => @user.preferred_language)
+ render :action => 'edit'
+ end
+ end
+
+ def edit
+ @title= t 'diary_entry.edit.title'
+ @diary_entry = DiaryEntry.find(params[:id])
+
+ if @user != @diary_entry.user
+ redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
+ elsif params[:diary_entry]
+ if @diary_entry.update_attributes(params[:diary_entry])
+ redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]