+ else
+ render :action => 'edit'
+ end
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def edit
+ @title= 'Edit diary entry'
+ @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]
+ @diary_entry.title = params[:diary_entry][:title]
+ @diary_entry.body = params[:diary_entry][:body]
+ @diary_entry.latitude = params[:diary_entry][:latitude]
+ @diary_entry.longitude = params[:diary_entry][:longitude]
+
+ if @diary_entry.save
+ redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]