From 5f1c2d57e7e787039033d390cd6ee4c8853d358a Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 6 Dec 2007 17:31:17 +0000 Subject: [PATCH] removing unnecessary helper methods git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@55 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/models/people.rb | 14 ++++++ app/views/layouts/application.rhtml | 1 + app/views/peoples/edit.rhtml | 1 + config/routes.rb | 2 + lib/actionview_text_helper.rb | 77 ----------------------------- 5 files changed, 18 insertions(+), 77 deletions(-) delete mode 100644 lib/actionview_text_helper.rb diff --git a/app/models/people.rb b/app/models/people.rb index cc1e6e8..d455d7d 100644 --- a/app/models/people.rb +++ b/app/models/people.rb @@ -3,4 +3,18 @@ # class People < ActiveRecord::Base has_one_tuxwiki_page :owner_class => 'People' + belongs_to :role + attr_protected :role_id + validates_presence_of :role_id + + before_create :set_base_role + + protected + + ## + # Sets the Role to the top level model. + # + def set_base_role + self.role = Role.base_role + end end diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 160031c..57c1529 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -33,6 +33,7 @@ <%= link_to_unless_current 'Browse Breweries', breweries_path -%>
<%= link_to_unless_current 'Discussions', discussions_path -%>
<%= link_to_unless_current 'Peoples', peoples_path -%>
+ <%= link_to_unless_current 'Roles', roles_path -%>

<%= yield :sidebar %> diff --git a/app/views/peoples/edit.rhtml b/app/views/peoples/edit.rhtml index 004541c..ccd2d38 100644 --- a/app/views/peoples/edit.rhtml +++ b/app/views/peoples/edit.rhtml @@ -8,5 +8,6 @@ <% end %> <% content_for :sidebar do -%> + <%= new_people_link %>
<%= show_people_link(@people) %>
<% end -%> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b3e8271..5c7745f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ ActionController::Routing::Routes.draw do |map| + map.resources :roles + map.resources :beers, :breweries, :pages, :discussions, :peoples map.connect ':controller/:action/:id.:format' diff --git a/lib/actionview_text_helper.rb b/lib/actionview_text_helper.rb deleted file mode 100644 index 673aa2d..0000000 --- a/lib/actionview_text_helper.rb +++ /dev/null @@ -1,77 +0,0 @@ -# ActionView Text Helpers are great! -# Let's extend the String class to allow us to call -# some of these methods directly on a String. -# Note: -# - cycle-related methods are not included -# - concat is not included -# - pluralize is not included because it is in -# ActiveSupport String extensions already -# (though they differ). -# - markdown requires BlueCloth -# - textilize methods require RedCloth -# Example: -# "coolness".strip_tags -> "coolness" -require 'singleton' -# Singleton to be called in wrapper module -class TextHelperSingleton - include Singleton - include ActionView::Helpers::TextHelper - include ActionView::Helpers::TagHelper #tag_options needed by auto_link -end -# Wrapper module -module MyExtensions #:nodoc: - module CoreExtensions #:nodoc: - module String #:nodoc: - module TextHelper - def auto_link(link = :all, href_options = {}, &block) - TextHelperSingleton.instance.auto_link(self, link, href_options, &block) - end - def excerpt(phrase, radius = 100, excerpt_string = "…") - TextHelperSingleton.instance.excerpt(self, phrase, radius, excerpt_string) - end - def highlight(phrase, highlighter = '\1') - TextHelperSingleton.instance.highlight(self, phrase, highlighter) - end - - begin - require_library_or_gem 'bluecloth' - def markdown - TextHelperSingleton.instance.markdown(self) - end - rescue LoadError - # do nothing. method will be undefined - end - def sanitize - TextHelperSingleton.instance.sanitize(self) - end - def simple_format - TextHelperSingleton.instance.simple_format(self) - end - def strip_tags - TextHelperSingleton.instance.strip_tags(self) - end - begin - require_library_or_gem 'redcloth' - def textilize - TextHelperSingleton.instance.textilize(self) - end - def textilize_without_paragraph - TextHelperSingleton.instance.textilize_without_paragraph(self) - end - rescue LoadError - # do nothing. methods will be undefined - end - def truncate(length = 30, truncate_string = "…") - TextHelperSingleton.instance.truncate(self, length, truncate_string) - end - def word_wrap(line_width = 80) - TextHelperSingleton.instance.word_wrap(self, line_width) - end - end - end - end -end -# extend String with the TextHelper functions -class String #:nodoc: - include MyExtensions::CoreExtensions::String::TextHelper -end