action links to prevent excess typing

git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@31 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7
master
andrew 2007-11-17 05:51:15 +00:00
parent 629cc9c2cc
commit 1e88dc6d10
9 changed files with 49 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -8,6 +8,6 @@
<% end -%>
<% content_for :sidebar do -%>
<%= link_to 'New Beer', new_beer_path -%><br />
<%= link_to 'Show', beer_path(@beer.page.title_for_url) -%><br />
<%= new_beer_link -%><br />
<%= show_beer_link(@beer) -%><br />
<% end -%>

View File

@ -1,6 +1,6 @@
<%= render :partial => 'pages/page' %>
<% content_for :sidebar do -%>
<%= link_to 'New Beer', new_beer_path -%><br />
<%= link_to 'Edit Beer', edit_beer_path(@beer.page.title_for_url) -%><br />
<%= new_beer_link -%><br />
<%= edit_beer_link(@beer) -%><br />
<% end -%>

View File

@ -10,6 +10,6 @@
<% end %>
<% content_for :sidebar do -%>
<%= link_to 'Show', page_path({ :id => @page.title_for_url }) %><br />
<%= link_to 'Browse Pages', pages_path %><br />
<%= new_page_link -%><br />
<%= show_page_link(@page) -%><br />
<% end -%>

View File

@ -1,5 +1,5 @@
<%= render :partial => 'page' -%>
<% content_for :sidebar do -%>
<%= link_to 'New Page', new_page_path -%><br />
<%= new_page_link -%><br />
<% end -%>

View File

@ -11,7 +11,3 @@
<%= submit_tag "Create" %>
</p>
<% end %>
<% content_for :sidebar do -%>
<%= link_to 'Browse Pages', pages_path %><br />
<% end -%>

View File

@ -1,6 +1,6 @@
<%= render :partial => 'page' %>
<% content_for :sidebar do -%>
<%= link_to 'Edit Page', edit_page_path({ :id => @page.title_for_url }) %><br />
<%= link_to 'Browse Pages', pages_path %><br />
<%= new_page_link -%><br />
<%= edit_page_link(@page) -%><br />
<% end -%>