From 1e88dc6d10d496bbaf74dad460ad82c248fed037 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 17 Nov 2007 05:51:15 +0000 Subject: [PATCH] action links to prevent excess typing git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@31 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/helpers/beers_helper.rb | 13 +++++++++++++ app/helpers/breweries_helper.rb | 14 ++++++++++++++ app/helpers/pages_helper.rb | 13 +++++++++++++ app/views/beers/edit.rhtml | 4 ++-- app/views/beers/show.rhtml | 4 ++-- app/views/pages/edit.rhtml | 4 ++-- app/views/pages/index.rhtml | 2 +- app/views/pages/new.rhtml | 4 ---- app/views/pages/show.rhtml | 4 ++-- 9 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/helpers/beers_helper.rb b/app/helpers/beers_helper.rb index 8bcf488..1b8047f 100644 --- a/app/helpers/beers_helper.rb +++ b/app/helpers/beers_helper.rb @@ -1,2 +1,15 @@ module BeersHelper + def new_beer_link + link_to 'New Beer', new_beer_path, { :title => 'Create a new beer' } + end + + def show_beer_link(beer) + link_to 'Show', beer_path(beer.page.title_for_url), + { :title => beer.title } + end + + def edit_beer_link(beer) + link_to 'Edit Beer', edit_beer_path(beer.page.title_for_url), + { :title => "Edit #{beer.title}" } + end end diff --git a/app/helpers/breweries_helper.rb b/app/helpers/breweries_helper.rb index 350d903..34a9fdd 100644 --- a/app/helpers/breweries_helper.rb +++ b/app/helpers/breweries_helper.rb @@ -1,2 +1,16 @@ module BreweriesHelper + def new_brewery_link + link_to 'New Brewery', new_brewery_path, + { :title => 'Create a new brewery' } + end + + def show_brewery_link(brewery) + link_to 'Show', brewery_path(brewery.page.title_for_url), + { :title => brewery.title } + end + + def edit_brewery_link(brewery) + link_to 'Edit Brewery', edit_brewery_path(brewery.page.title_for_url), + { :title => "Edit #{brewery.title}" } + end end diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb index 2c057fd..97cf900 100644 --- a/app/helpers/pages_helper.rb +++ b/app/helpers/pages_helper.rb @@ -1,2 +1,15 @@ module PagesHelper + def new_page_link + link_to 'New Page', new_page_path, { :title => 'Create a new page' } + end + + def show_page_link(page) + link_to 'Show', page_path(page.title_for_url), + { :title => page.title } + end + + def edit_page_link(page) + link_to 'Edit Page', edit_page_path(page.title_for_url), + { :title => "Edit #{page.title}" } + end end diff --git a/app/views/beers/edit.rhtml b/app/views/beers/edit.rhtml index 28136e5..f2deb88 100644 --- a/app/views/beers/edit.rhtml +++ b/app/views/beers/edit.rhtml @@ -8,6 +8,6 @@ <% end -%> <% content_for :sidebar do -%> - <%= link_to 'New Beer', new_beer_path -%>
- <%= link_to 'Show', beer_path(@beer.page.title_for_url) -%>
+ <%= new_beer_link -%>
+ <%= show_beer_link(@beer) -%>
<% end -%> diff --git a/app/views/beers/show.rhtml b/app/views/beers/show.rhtml index 4ee0cb3..0f55aed 100644 --- a/app/views/beers/show.rhtml +++ b/app/views/beers/show.rhtml @@ -1,6 +1,6 @@ <%= render :partial => 'pages/page' %> <% content_for :sidebar do -%> - <%= link_to 'New Beer', new_beer_path -%>
- <%= link_to 'Edit Beer', edit_beer_path(@beer.page.title_for_url) -%>
+ <%= new_beer_link -%>
+ <%= edit_beer_link(@beer) -%>
<% end -%> diff --git a/app/views/pages/edit.rhtml b/app/views/pages/edit.rhtml index 230ea06..00d057a 100644 --- a/app/views/pages/edit.rhtml +++ b/app/views/pages/edit.rhtml @@ -10,6 +10,6 @@ <% end %> <% content_for :sidebar do -%> - <%= link_to 'Show', page_path({ :id => @page.title_for_url }) %>
- <%= link_to 'Browse Pages', pages_path %>
+ <%= new_page_link -%>
+ <%= show_page_link(@page) -%>
<% end -%> diff --git a/app/views/pages/index.rhtml b/app/views/pages/index.rhtml index 1da608e..fa2b8d4 100644 --- a/app/views/pages/index.rhtml +++ b/app/views/pages/index.rhtml @@ -1,5 +1,5 @@ <%= render :partial => 'page' -%> <% content_for :sidebar do -%> - <%= link_to 'New Page', new_page_path -%>
+ <%= new_page_link -%>
<% end -%> diff --git a/app/views/pages/new.rhtml b/app/views/pages/new.rhtml index 3df8b2c..88f7bf4 100644 --- a/app/views/pages/new.rhtml +++ b/app/views/pages/new.rhtml @@ -11,7 +11,3 @@ <%= submit_tag "Create" %>

<% end %> - -<% content_for :sidebar do -%> - <%= link_to 'Browse Pages', pages_path %>
-<% end -%> \ No newline at end of file diff --git a/app/views/pages/show.rhtml b/app/views/pages/show.rhtml index c6b21e1..b06733f 100644 --- a/app/views/pages/show.rhtml +++ b/app/views/pages/show.rhtml @@ -1,6 +1,6 @@ <%= render :partial => 'page' %> <% content_for :sidebar do -%> - <%= link_to 'Edit Page', edit_page_path({ :id => @page.title_for_url }) %>
- <%= link_to 'Browse Pages', pages_path %>
+ <%= new_page_link -%>
+ <%= edit_page_link(@page) -%>
<% end -%>