Skip to content

Commit

Permalink
added more navigation options to content_pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
drobin03 committed Feb 4, 2015
1 parent b70d04c commit 280e996
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/smithy/content_pieces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Smithy::ContentPiecesController < Smithy::BaseController

helper_method :accessible_attributes
helper_method :klass_name
helper_method :klass_table_name
helper_method :readable_attributes

def index
Expand Down Expand Up @@ -67,6 +68,10 @@ def klass_name
@klass_name ||= klass.name.sub(/^Smithy::/, '').titleize
end

def klass_table_name
klass.name.sub(/^Smithy::/, '').underscore.pluralize
end

def new_record
klass.new(filtered_params)
end
Expand Down
7 changes: 6 additions & 1 deletion app/views/smithy/content_pieces/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<%= f.inputs do %>
<%= f.inputs *accessible_attributes %>
<% end %>
<%= f.actions :submit %>
<%= f.actions do %>
<%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
<span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
<% end %>
<%= f.action :submit %>
<% end %>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/smithy/content_pieces/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<% content_for :title, "#{klass_name}" %>
<%= content_tag :p, link_to("New #{klass_name}", [:new, klass_table_name.singularize ], class: 'btn btn-primary') %></p>

<table border="0" cellpadding="4" class="table table-hover table-bordered">
<thead>
<tr>
Expand All @@ -11,6 +14,7 @@
<tr>
<td>
<%= link_to "Edit", [:edit, record], :class => "btn btn-default btn-xs" %>
<%= link_to("Delete", record, method: :delete, data: { confirm: "Are you sure you want to delete this #{klass_name}?" }, class: 'btn btn-danger btn-xs') if record.persisted? %>
</td>
<%- readable_attributes.map(&:to_sym).each do |attribute| %>
<td><%= record[attribute] %></td>
Expand Down
7 changes: 6 additions & 1 deletion app/views/smithy/content_pieces/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<%= f.inputs do %>
<%= f.inputs *accessible_attributes %>
<% end %>
<%= f.actions :submit %>
<%= f.actions do %>
<%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
<span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
<% end %>
<%= f.action :submit %>
<% end %>
<% end %>

0 comments on commit 280e996

Please sign in to comment.