test_app_as_gem 0.01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/application_controller.rb +3 -0
- data/app/controllers/entries_controller.rb +83 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/entries_helper.rb +2 -0
- data/app/models/entry.rb +2 -0
- data/app/views/entries/_form.html.erb +25 -0
- data/app/views/entries/edit.html.erb +6 -0
- data/app/views/entries/index.html.erb +25 -0
- data/app/views/entries/new.html.erb +5 -0
- data/app/views/entries/show.html.erb +15 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/db/migrate/20100930064937_create_entries.rb +14 -0
- metadata +77 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class EntriesController < ApplicationController
|
|
2
|
+
# GET /entries
|
|
3
|
+
# GET /entries.xml
|
|
4
|
+
def index
|
|
5
|
+
@entries = Entry.all
|
|
6
|
+
|
|
7
|
+
respond_to do |format|
|
|
8
|
+
format.html # index.html.erb
|
|
9
|
+
format.xml { render :xml => @entries }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /entries/1
|
|
14
|
+
# GET /entries/1.xml
|
|
15
|
+
def show
|
|
16
|
+
@entry = Entry.find(params[:id])
|
|
17
|
+
|
|
18
|
+
respond_to do |format|
|
|
19
|
+
format.html # show.html.erb
|
|
20
|
+
format.xml { render :xml => @entry }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# GET /entries/new
|
|
25
|
+
# GET /entries/new.xml
|
|
26
|
+
def new
|
|
27
|
+
@entry = Entry.new
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html # new.html.erb
|
|
31
|
+
format.xml { render :xml => @entry }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# GET /entries/1/edit
|
|
36
|
+
def edit
|
|
37
|
+
@entry = Entry.find(params[:id])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# POST /entries
|
|
41
|
+
# POST /entries.xml
|
|
42
|
+
def create
|
|
43
|
+
@entry = Entry.new(params[:entry])
|
|
44
|
+
|
|
45
|
+
respond_to do |format|
|
|
46
|
+
if @entry.save
|
|
47
|
+
format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
|
|
48
|
+
format.xml { render :xml => @entry, :status => :created, :location => @entry }
|
|
49
|
+
else
|
|
50
|
+
format.html { render :action => "new" }
|
|
51
|
+
format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /entries/1
|
|
57
|
+
# PUT /entries/1.xml
|
|
58
|
+
def update
|
|
59
|
+
@entry = Entry.find(params[:id])
|
|
60
|
+
|
|
61
|
+
respond_to do |format|
|
|
62
|
+
if @entry.update_attributes(params[:entry])
|
|
63
|
+
format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }
|
|
64
|
+
format.xml { head :ok }
|
|
65
|
+
else
|
|
66
|
+
format.html { render :action => "edit" }
|
|
67
|
+
format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DELETE /entries/1
|
|
73
|
+
# DELETE /entries/1.xml
|
|
74
|
+
def destroy
|
|
75
|
+
@entry = Entry.find(params[:id])
|
|
76
|
+
@entry.destroy
|
|
77
|
+
|
|
78
|
+
respond_to do |format|
|
|
79
|
+
format.html { redirect_to(entries_url) }
|
|
80
|
+
format.xml { head :ok }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/app/models/entry.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%= form_for(@entry) do |f| %>
|
|
2
|
+
<% if @entry.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@entry.errors.count, "error") %> prohibited this entry from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @entry.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :title %><br />
|
|
16
|
+
<%= f.text_field :title %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :description %><br />
|
|
20
|
+
<%= f.text_field :description %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="actions">
|
|
23
|
+
<%= f.submit %>
|
|
24
|
+
</div>
|
|
25
|
+
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<h1>Listing entries</h1>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th>Title</th>
|
|
6
|
+
<th>Description</th>
|
|
7
|
+
<th></th>
|
|
8
|
+
<th></th>
|
|
9
|
+
<th></th>
|
|
10
|
+
</tr>
|
|
11
|
+
|
|
12
|
+
<% @entries.each do |entry| %>
|
|
13
|
+
<tr>
|
|
14
|
+
<td><%= entry.title %></td>
|
|
15
|
+
<td><%= entry.description %></td>
|
|
16
|
+
<td><%= link_to 'Show', entry %></td>
|
|
17
|
+
<td><%= link_to 'Edit', edit_entry_path(entry) %></td>
|
|
18
|
+
<td><%= link_to 'Destroy', entry, :confirm => 'Are you sure?', :method => :delete %></td>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</table>
|
|
22
|
+
|
|
23
|
+
<br />
|
|
24
|
+
|
|
25
|
+
<%= link_to 'New Entry', new_entry_path %>
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: test_app_as_gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 9
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
version: "0.01"
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- Tom Rothe
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2010-09-30 00:00:00 +02:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies: []
|
|
20
|
+
|
|
21
|
+
description: So far this is only a test gem
|
|
22
|
+
email: info@tomrothe.de
|
|
23
|
+
executables: []
|
|
24
|
+
|
|
25
|
+
extensions: []
|
|
26
|
+
|
|
27
|
+
extra_rdoc_files: []
|
|
28
|
+
|
|
29
|
+
files:
|
|
30
|
+
- app/controllers/application_controller.rb
|
|
31
|
+
- app/controllers/entries_controller.rb
|
|
32
|
+
- app/helpers/application_helper.rb
|
|
33
|
+
- app/helpers/entries_helper.rb
|
|
34
|
+
- app/models/entry.rb
|
|
35
|
+
- app/views/entries/_form.html.erb
|
|
36
|
+
- app/views/entries/edit.html.erb
|
|
37
|
+
- app/views/entries/index.html.erb
|
|
38
|
+
- app/views/entries/new.html.erb
|
|
39
|
+
- app/views/entries/show.html.erb
|
|
40
|
+
- app/views/layouts/application.html.erb
|
|
41
|
+
- db/migrate/20100930064937_create_entries.rb
|
|
42
|
+
has_rdoc: true
|
|
43
|
+
homepage: ""
|
|
44
|
+
licenses: []
|
|
45
|
+
|
|
46
|
+
post_install_message:
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
hash: 3
|
|
57
|
+
segments:
|
|
58
|
+
- 0
|
|
59
|
+
version: "0"
|
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
|
+
none: false
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
hash: 3
|
|
66
|
+
segments:
|
|
67
|
+
- 0
|
|
68
|
+
version: "0"
|
|
69
|
+
requirements: []
|
|
70
|
+
|
|
71
|
+
rubyforge_project:
|
|
72
|
+
rubygems_version: 1.3.7
|
|
73
|
+
signing_key:
|
|
74
|
+
specification_version: 3
|
|
75
|
+
summary: Just a test
|
|
76
|
+
test_files: []
|
|
77
|
+
|