--- /dev/null
+class ArcsController < ApplicationController
+ # GET /arcs
+ # GET /arcs.xml
+ def index
+ @arcs = Arc.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @arcs }
+ end
+ end
+
+ # GET /arcs/1
+ # GET /arcs/1.xml
+ def show
+ @arc = Arc.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @arc }
+ end
+ end
+
+ # GET /arcs/new
+ # GET /arcs/new.xml
+ def new
+ @arc = Arc.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @arc }
+ end
+ end
+
+ # GET /arcs/1/edit
+ def edit
+ @arc = Arc.find(params[:id])
+ end
+
+ # POST /arcs
+ # POST /arcs.xml
+ def create
+ @arc = Arc.new(params[:arc])
+
+ respond_to do |format|
+ if @arc.save
+ flash[:notice] = 'Arc was successfully created.'
+ format.html { redirect_to(@arc) }
+ format.xml { render :xml => @arc, :status => :created, :location => @arc }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @arc.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /arcs/1
+ # PUT /arcs/1.xml
+ def update
+ @arc = Arc.find(params[:id])
+
+ respond_to do |format|
+ if @arc.update_attributes(params[:arc])
+ flash[:notice] = 'Arc was successfully updated.'
+ format.html { redirect_to(@arc) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @arc.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /arcs/1
+ # DELETE /arcs/1.xml
+ def destroy
+ @arc = Arc.find(params[:id])
+ @arc.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(arcs_url) }
+ format.xml { head :ok }
+ end
+ end
+end
--- /dev/null
+module ArcsHelper
+end
--- /dev/null
+class Arc < ActiveRecord::Base
+ belongs_to :location
+end
--- /dev/null
+<h1>Editing arc</h1>
+
+<% form_for(@arc) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :code %><br />
+ <%= f.text_field :code %>
+ </p>
+ <p>
+ <%= f.label :extname %><br />
+ <%= f.text_field :extname %>
+ </p>
+ <p>
+ <%= f.label :location %><br />
+ <%= f.text_field :location %>
+ </p>
+ <p>
+ <%= f.label :summary %><br />
+ <%= f.text_field :summary %>
+ </p>
+ <p>
+ <%= f.label :origname %><br />
+ <%= f.text_field :origname %>
+ </p>
+ <p>
+ <%= f.submit 'Update' %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @arc %> |
+<%= link_to 'Back', arcs_path %>
\ No newline at end of file
--- /dev/null
+<h1>Listing arcs</h1>
+
+<table>
+ <tr>
+ <th>Code</th>
+ <th>Extname</th>
+ <th>Location</th>
+ <th>Summary</th>
+ <th>Origname</th>
+ </tr>
+
+<% @arcs.each do |arc| %>
+ <tr>
+ <td><%=h arc.code %></td>
+ <td><%=h arc.extname %></td>
+ <td><%=h arc.location %></td>
+ <td><%=h arc.summary %></td>
+ <td><%=h arc.origname %></td>
+ <td><%= link_to 'Show', arc %></td>
+ <td><%= link_to 'Edit', edit_arc_path(arc) %></td>
+ <td><%= link_to 'Destroy', arc, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New arc', new_arc_path %>
\ No newline at end of file
--- /dev/null
+<h1>New arc</h1>
+
+<% form_for(@arc) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :code %><br />
+ <%= f.text_field :code %>
+ </p>
+ <p>
+ <%= f.label :extname %><br />
+ <%= f.text_field :extname %>
+ </p>
+ <p>
+ <%= f.label :location %><br />
+ <%= f.text_field :location %>
+ </p>
+ <p>
+ <%= f.label :summary %><br />
+ <%= f.text_field :summary %>
+ </p>
+ <p>
+ <%= f.label :origname %><br />
+ <%= f.text_field :origname %>
+ </p>
+ <p>
+ <%= f.submit 'Create' %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', arcs_path %>
\ No newline at end of file
--- /dev/null
+<p>
+ <b>Code:</b>
+ <%=h @arc.code %>
+</p>
+
+<p>
+ <b>Extname:</b>
+ <%=h @arc.extname %>
+</p>
+
+<p>
+ <b>Location:</b>
+ <%=h @arc.location %>
+</p>
+
+<p>
+ <b>Summary:</b>
+ <%=h @arc.summary %>
+</p>
+
+<p>
+ <b>Origname:</b>
+ <%=h @arc.origname %>
+</p>
+
+
+<%= link_to 'Edit', edit_arc_path(@arc) %> |
+<%= link_to 'Back', arcs_path %>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>Arcs: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>
ActionController::Routing::Routes.draw do |map|
+ map.resources :arcs
+
map.resources :locations
# The priority is based upon order of creation: first created -> highest priority.
--- /dev/null
+class CreateArcs < ActiveRecord::Migration
+ def self.up
+ create_table :arcs do |t|
+ t.string :code, :null => false, :limit => 10
+ t.string :extname, :null => false, :limit => 10
+ t.references :location
+ t.string :summary
+ t.string :origname
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :arcs
+ end
+end
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100608074721) do
+ActiveRecord::Schema.define(:version => 20100608080758) do
+
+ create_table "arcs", :force => true do |t|
+ t.string "code", :limit => 10, :null => false
+ t.string "extname", :limit => 10, :null => false
+ t.integer "location_id"
+ t.string "summary"
+ t.string "origname"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "locations", :force => true do |t|
t.string "code", :limit => 10, :null => false
--- /dev/null
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ id: 1
+ code: MyString
+ extname: MyString
+ location_id: 1
+ summary: MyString
+ origname: MyString
+
+two:
+ id: 2
+ code: MyString
+ extname: MyString
+ location_id: 1
+ summary: MyString
+ origname: MyString
--- /dev/null
+require 'test_helper'
+
+class ArcsControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:arcs)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create arc" do
+ assert_difference('Arc.count') do
+ post :create, :arc => { :code => 'up0001', :extname => 'zip' }
+ end
+
+ assert_redirected_to arc_path(assigns(:arc))
+ end
+
+ test "should show arc" do
+ get :show, :id => arcs(:one).to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => arcs(:one).to_param
+ assert_response :success
+ end
+
+ test "should update arc" do
+ put :update, :id => arcs(:one).to_param, :arc => { }
+ assert_redirected_to arc_path(assigns(:arc))
+ end
+
+ test "should destroy arc" do
+ assert_difference('Arc.count', -1) do
+ delete :destroy, :id => arcs(:one).to_param
+ end
+
+ assert_redirected_to arcs_path
+ end
+end
--- /dev/null
+require 'test_helper'
+
+class ArcTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
--- /dev/null
+require 'test_helper'
+
+class ArcsHelperTest < ActionView::TestCase
+end