Permalink
Browse files

small fixes

  • Loading branch information...
1 parent 8ccda5f commit 958cff15fad08f04596db849ae72ced1edfc762e @NVR committed Nov 7, 2011
Showing with 8 additions and 12 deletions.
  1. +4 −7 app/controllers/notes_controller.rb
  2. +1 −1 app/views/notes/_form.html.slim
  3. +2 −3 app/views/notes/topics.html.slim
  4. +1 −1 config/routes.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
@@ -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
@@ -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
@@ -4,7 +4,7 @@
devise_for :users
- resources :notes
+ resources :notes
root :to => "notes#index"

0 comments on commit 958cff1

Please sign in to comment.