Permalink
Browse files

tracking list CRUD

  • Loading branch information...
1 parent 5e0b719 commit 56b9682483fad59d1af9f71db434c5b773d5c638 @noel noel committed Apr 30, 2012
@@ -2,24 +2,19 @@ class TrackingListsController < ApplicationController
# Prevents the following error from showing up, common in Rails engines
# A copy of ApplicationController has been removed from the module tree but is still active!
unloadable
-
- before_filter :get_trackable_items_user
- before_filter :get_tracking_list
-
+
def show
- respond_to do |format|
- format.html
- end
+ @tracking_list = TrackingList.find(params[:id])
end
-
- protected
- def get_trackable_items_user
- @trackable_items_user = User.find(params[:user_id])
+ def index
+ @tracking_lists = TrackingList.all
end
- def get_tracking_list
- @tracking_list = @trackable_items_user.tracking_list
+ def new
+ @tracking_list = TrackingList.new
+ @tracking_list.save
+ render :action => "show",:id=>@tracking_list.id
end
-
+
end
@@ -2,16 +2,17 @@
<table>
<tr>
- <th>Title</th>
+ <th>ID</th>
<th></th>
<th></th>
</tr>
<% @tracking_lists.each do |tracking_list| %>
<tr>
- <td><%= tracking_list.title %></td>
- <td><%= link_to 'Show', tracking_list %></td>
- <td><%= link_to 'Edit', edit_tracking_list_path(tracking_list) %></td>
+ <td><%= tracking_list.id %></td>
+ <td><%= link_to 'Show', url_for_tracking_list(tracking_list.id) %></td>
</tr>
<% end %>
-</table>
+</table>
+
+<%= link_to "Create New Tracking List" , url_for_new_tracking_list %>
View
@@ -1,7 +1,7 @@
require 'trackable_items'
# Routes needs more thought since some default routes in ArchivesCentral are taking precedence.
ActionController::Routing::Routes.draw do |map|
- map.resources :tracking_lists, :path_prefix => ':urlified_name', :only => [:show, :index]
+ map.resources :tracking_lists, :path_prefix => ':urlified_name', :only => [:show, :new, :index]
map.resources :repositories, :path_prefix => ':urlified_name'
map.resources :shelf_locations, :path_prefix => ':urlified_name'
end
@@ -6,6 +6,7 @@ def self.included(klass)
module UrlFor
+ # Repository URLs
def url_for_repository(repo_id)
url_for(
:controller => "repositories",
@@ -44,6 +45,7 @@ def url_for_new_repository
:urlified_name => @current_basket.urlified_name)
end
+ # Shelf Location URLs
def url_for_shelf_location(shelf_id)
url_for(
:controller => "shelf_locations",
@@ -67,6 +69,22 @@ def url_to_edit_shelf_location(shelf_id)
:urlified_name => @current_basket.urlified_name,
:id => shelf_id)
end
+
+ #Tracking List URLs
+ def url_for_tracking_list(tracking_list_id)
+ url_for(
+ :controller => "tracking_lists",
+ :action => :show,
+ :urlified_name => @current_basket.urlified_name,
+ :id => tracking_list_id)
+ end
+
+ def url_for_new_tracking_list
+ url_for(
+ :controller => "tracking_lists",
+ :action => :new,
+ :urlified_name => @current_basket.urlified_name)
+ end
end
end

0 comments on commit 56b9682

Please sign in to comment.