Skip to content

Commit

Permalink
scaffold working
Browse files Browse the repository at this point in the history
  • Loading branch information
burnto committed Sep 23, 2009
1 parent 55077e4 commit 5930a86
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 54,902 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
db/openstudio.data
db/*.sqlite3
tmp/*
.DS_Store
.DS_Store
public/os
log/*
9 changes: 9 additions & 0 deletions app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
class MembersController < ApplicationController

def index
@members = Member.all
end

def show
@member = Member.find(params[:id])
end

end
5 changes: 5 additions & 0 deletions app/controllers/pieces_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class PiecesController < ApplicationController

def show
@piece = Piece.find(params[:id])
end

end
5 changes: 5 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class Member < ActiveRecord::Base
has_many :created, :foreign_key => "creator_id", :class_name => "Piece"
has_many :owned, :foreign_key => "owner_id", :class_name => "Piece"

default_scope :order => "name asc, login asc"

end
3 changes: 3 additions & 0 deletions app/models/piece.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
class Piece < ActiveRecord::Base
belongs_to :owner, :class_name => "Member"
belongs_to :creator, :class_name => "Member"

named_scope :sold, :conditions => "owner_id != creator_id"
end
13 changes: 13 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>OPENSTUDIO Archives</title>
</head>

<body>
<%= yield %>
</body>
</html>
3 changes: 3 additions & 0 deletions app/views/members/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% @members.each do |member| %>
<%= link_to h(member.name), member_path(member) %>
<% end %>
12 changes: 12 additions & 0 deletions app/views/members/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1><%= @member.name %></h1>
<p>(<%= @member.login %>)</p>

<h2>Purchased</h2>
<% @member.owned.sold.each do |piece| %>
<%= link_to h(piece.title), piece_path(piece) %>
<% end %>

<h2>Portfolio</h2>
<% @member.created.each do |piece| %>
<%= link_to h(piece.title), piece_path(piece) %>
<% end %>
14 changes: 14 additions & 0 deletions app/views/pieces/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h1><%= @piece.title %></h1>

<div>
<%= image_tag "/os/500/#{@piece.legacy_id}.png" %>
</div>

<p>
Creator: <%= link_to h(@piece.creator.name), member_path(@piece.creator) %>
</p>

<p>
Owner: <%= link_to h(@piece.owner.name), member_path(@piece.owner) %>
</p>

40 changes: 0 additions & 40 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,7 @@
ActionController::Routing::Routes.draw do |map|
map.resources :pieces

map.resources :members

# The priority is based upon order of creation: first created -> highest priority.

# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action

# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)

# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products

# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end

# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end

# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"

# See how all your routes lay out with "rake routes"

# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing or commenting them out if you're using named routes and resources.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
2 changes: 1 addition & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require File.join(File.dirname(__FILE__), "..", "config", "environment.rb")

# Load meta
OS_DATA_DIR = File.join(RAILS_ROOT, "db", "openstudio.data")
OS_DATA_DIR = File.join(RAILS_ROOT, "..", "openstudio.data")
META_DATA_DIR = File.join(OS_DATA_DIR, "meta")


Expand Down
54,860 changes: 0 additions & 54,860 deletions log/development.log

This file was deleted.

0 comments on commit 5930a86

Please sign in to comment.