--- /dev/null
+*.swp
+log/*.log
--- /dev/null
+class LocationsController < ApplicationController
+ # GET /locations
+ # GET /locations.xml
+ def index
+ @locations = Location.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @locations }
+ end
+ end
+
+ # GET /locations/1
+ # GET /locations/1.xml
+ def show
+ @location = Location.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @location }
+ end
+ end
+
+ # GET /locations/new
+ # GET /locations/new.xml
+ def new
+ @location = Location.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @location }
+ end
+ end
+
+ # GET /locations/1/edit
+ def edit
+ @location = Location.find(params[:id])
+ end
+
+ # POST /locations
+ # POST /locations.xml
+ def create
+ @location = Location.new(params[:location])
+
+ respond_to do |format|
+ if @location.save
+ flash[:notice] = 'Location was successfully created.'
+ format.html { redirect_to(@location) }
+ format.xml { render :xml => @location, :status => :created, :location => @location }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /locations/1
+ # PUT /locations/1.xml
+ def update
+ @location = Location.find(params[:id])
+
+ respond_to do |format|
+ if @location.update_attributes(params[:location])
+ flash[:notice] = 'Location was successfully updated.'
+ format.html { redirect_to(@location) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /locations/1
+ # DELETE /locations/1.xml
+ def destroy
+ @location = Location.find(params[:id])
+ @location.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(locations_url) }
+ format.xml { head :ok }
+ end
+ end
+end
--- /dev/null
+module LocationsHelper
+end
--- /dev/null
+class Location < ActiveRecord::Base
+end
--- /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>Locations: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>
--- /dev/null
+<h1>Editing location</h1>
+
+<% form_for(@location) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :code %><br />
+ <%= f.text_field :code %>
+ </p>
+ <p>
+ <%= f.label :site %><br />
+ <%= f.text_field :site %>
+ </p>
+ <p>
+ <%= f.label :summary %><br />
+ <%= f.text_field :summary %>
+ </p>
+ <p>
+ <%= f.submit 'Update' %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @location %> |
+<%= link_to 'Back', locations_path %>
\ No newline at end of file
--- /dev/null
+<h1>Listing locations</h1>
+
+<table>
+ <tr>
+ <th>Code</th>
+ <th>Site</th>
+ <th>Summary</th>
+ </tr>
+
+<% @locations.each do |location| %>
+ <tr>
+ <td><%=h location.code %></td>
+ <td><%=h location.site %></td>
+ <td><%=h location.summary %></td>
+ <td><%= link_to 'Show', location %></td>
+ <td><%= link_to 'Edit', edit_location_path(location) %></td>
+ <td><%= link_to 'Destroy', location, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New location', new_location_path %>
\ No newline at end of file
--- /dev/null
+<h1>New location</h1>
+
+<% form_for(@location) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :code %><br />
+ <%= f.text_field :code %>
+ </p>
+ <p>
+ <%= f.label :site %><br />
+ <%= f.text_field :site %>
+ </p>
+ <p>
+ <%= f.label :summary %><br />
+ <%= f.text_field :summary %>
+ </p>
+ <p>
+ <%= f.submit 'Create' %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', locations_path %>
\ No newline at end of file
--- /dev/null
+<p>
+ <b>Code:</b>
+ <%=h @location.code %>
+</p>
+
+<p>
+ <b>Site:</b>
+ <%=h @location.site %>
+</p>
+
+<p>
+ <b>Summary:</b>
+ <%=h @location.summary %>
+</p>
+
+
+<%= link_to 'Edit', edit_location_path(@location) %> |
+<%= link_to 'Back', locations_path %>
\ No newline at end of file
ActionController::Routing::Routes.draw do |map|
+ map.resources :locations
+
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
--- /dev/null
+class CreateLocations < ActiveRecord::Migration
+ def self.up
+ create_table :locations do |t|
+ t.string :code, :null => false, :limit => 10
+ t.string :site, :null => false
+ t.string :summary, :null => false
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :locations
+ end
+end
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 0) do
+ActiveRecord::Schema.define(:version => 20100608074721) do
+
+ create_table "locations", :force => true do |t|
+ t.string "code", :limit => 10, :null => false
+ t.string "site", :null => false
+ t.string "summary", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
end
+++ /dev/null
- \e[4;36;1mSQL (0.1ms)\e[0m \e[0;1mSET client_min_messages TO 'panic'\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET client_min_messages TO 'notice'\e[0m
- \e[4;36;1mSQL (4.4ms)\e[0m \e[0;1mCREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) \e[0m
- \e[4;35;1mSQL (2.7ms)\e[0m \e[0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")\e[0m
- \e[4;36;1mSQL (0.3ms)\e[0m \e[0;1mSELECT version FROM schema_migrations\e[0m
- \e[4;36;1mSQL (0.1ms)\e[0m \e[0;1mSET client_min_messages TO 'panic'\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET client_min_messages TO 'notice'\e[0m
- \e[4;36;1mSQL (0.3ms)\e[0m \e[0;1mSELECT version FROM schema_migrations\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET client_min_messages TO 'panic'\e[0m
- \e[4;36;1mSQL (0.1ms)\e[0m \e[0;1mSET client_min_messages TO 'notice'\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET search_path TO public\e[0m
- \e[4;36;1mSQL (205.3ms)\e[0m \e[0;1mDROP DATABASE IF EXISTS "nimono_test"\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET client_min_messages TO 'panic'\e[0m
- \e[4;36;1mSQL (0.2ms)\e[0m \e[0;1mSET client_min_messages TO 'notice'\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET search_path TO public\e[0m
- \e[4;36;1mSQL (370.9ms)\e[0m \e[0;1mCREATE DATABASE "nimono_test" ENCODING = 'utf8'\e[0m
- \e[4;35;1mSQL (0.1ms)\e[0m \e[0mSET client_min_messages TO 'panic'\e[0m
- \e[4;36;1mSQL (0.1ms)\e[0m \e[0;1mSET client_min_messages TO 'notice'\e[0m
- \e[4;35;1mSQL (3.9ms)\e[0m \e[0mCREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) \e[0m
- \e[4;36;1mSQL (2.7ms)\e[0m \e[0;1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")\e[0m
- \e[4;35;1mSQL (0.3ms)\e[0m \e[0mSELECT version FROM "schema_migrations"\e[0m
- \e[4;36;1mSQL (0.9ms)\e[0m \e[0;1mINSERT INTO "schema_migrations" (version) VALUES ('0')\e[0m
--- /dev/null
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
--- /dev/null
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ id: 1
+ code: MyString
+ site: MyString
+ summary: MyString
+
+two:
+ id: 2
+ code: MyString
+ site: MyString
+ summary: MyString
--- /dev/null
+require 'test_helper'
+
+class LocationsControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:locations)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create location" do
+ assert_difference('Location.count') do
+ post :create, :location => { :code => 'mmd', :site => 'http://mmd.nomeu.org', :summary => 'mmd uploader by nomeu' }
+ end
+
+ assert_redirected_to location_path(assigns(:location))
+ end
+
+ test "should show location" do
+ get :show, :id => locations(:one).to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => locations(:one).to_param
+ assert_response :success
+ end
+
+ test "should update location" do
+ put :update, :id => locations(:one).to_param, :location => { }
+ assert_redirected_to location_path(assigns(:location))
+ end
+
+ test "should destroy location" do
+ assert_difference('Location.count', -1) do
+ delete :destroy, :id => locations(:one).to_param
+ end
+
+ assert_redirected_to locations_path
+ end
+end
--- /dev/null
+require 'test_helper'
+
+class LocationsHelperTest < ActionView::TestCase
+end
--- /dev/null
+require 'test_helper'
+
+class LocationTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end