Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

small fixes

  • Loading branch information...
commit 958cff15fad08f04596db849ae72ced1edfc762e 1 parent 8ccda5f
@NVR authored
View
11 app/controllers/notes_controller.rb
@@ -5,15 +5,13 @@ class NotesController < ApplicationController
helper_method :not_current?
before_filter :can_edit?, :only => [:edit, :delete]
-
def page_exceedance?
if params[:page].to_i > Note.pages_count
params[:page] = (Note.pages_count).to_s
end
end
-
+
def topics
- @title = 'Topics'
if params[:topic_id].present?
@topic = Topic.find(params[:topic_id])
if params[:search].present?
@@ -25,6 +23,7 @@ def topics
@count = Topic.find(params[:topic_id]).notes.count
end
end
+ @title = "Notes associated with #{@topic.name}"
end
def index
@@ -98,17 +97,16 @@ def destroy
redirect_to notes_url
end
-
def not_current?(note)
- note.id == Note.find(params[:id]).id
+ note.id == Note.find(params[:id]).id
end
-
def search
@searchresult = Note.search(params[:search])
end
private
+
def can_edit?
@note = Note.find(params[:id])
unless editable?(@note)
@@ -120,5 +118,4 @@ def editable?(note)
user_signed_in? && (current_user.id == note.user_id)
end
-
end
View
2  app/views/notes/_form.html.slim
@@ -16,7 +16,7 @@
div.clearfix
= f.label "Topics"
- - for topic in Topic.find(:all)
+ - for topic in Topic.all
div.input.checkbox
= check_box_tag "note[topic_ids][]", topic.id, @note.topics.include?(topic)
= topic.name
View
5 app/views/notes/topics.html.slim
@@ -1,6 +1,5 @@
div.indexcenter
- - @title ='Notes associated with ' + @topic.name
- = render :partial => 'notes/search'
+ = render 'notes/search'
- if params[:topic_id].present?
- = render :partial => 'index'
+ = render 'index'
View
2  config/routes.rb
@@ -4,7 +4,7 @@
devise_for :users
- resources :notes
+ resources :notes
root :to => "notes#index"
Please sign in to comment.
Something went wrong with that request. Please try again.