rails 0.8.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +86 -0
- data/README +48 -8
- data/Rakefile +87 -108
- data/bin/breakpointer +3 -0
- data/bin/breakpointer_for_gem +4 -0
- data/bin/console +30 -0
- data/bin/generate +41 -0
- data/bin/rails +1 -1
- data/{dispatches/dispatch.servlet → bin/server} +15 -11
- data/configs/apache.conf +12 -27
- data/configs/database.yml +9 -2
- data/dispatches/dispatch.fcgi +2 -2
- data/dispatches/dispatch.rb +2 -2
- data/doc/index.html +12 -36
- data/environments/development.rb +5 -0
- data/environments/production.rb +3 -6
- data/environments/shared.rb +46 -20
- data/environments/shared_for_gem.rb +41 -8
- data/environments/test.rb +3 -6
- data/fresh_rakefile +25 -21
- data/generators/controller/USAGE +28 -0
- data/generators/controller/controller_generator.rb +22 -0
- data/generators/controller/templates/controller.rb +10 -0
- data/generators/{templates/controller_test.erb → controller/templates/functional_test.rb} +1 -1
- data/generators/{templates/helper.erb → controller/templates/helper.rb} +0 -0
- data/generators/controller/templates/view.rhtml +2 -0
- data/generators/mailer/USAGE +27 -0
- data/generators/mailer/mailer_generator.rb +22 -0
- data/generators/{templates/mailer_action.rhtml → mailer/templates/fixture.rhtml} +0 -0
- data/generators/{templates/mailer.erb → mailer/templates/mailer.rb} +4 -4
- data/generators/{templates/mailer_test.erb → mailer/templates/unit_test.rb} +2 -10
- data/generators/mailer/templates/view.rhtml +3 -0
- data/generators/model/USAGE +17 -0
- data/generators/model/model_generator.rb +10 -0
- data/generators/model/templates/fixtures.yml +1 -0
- data/generators/{templates/model.erb → model/templates/model.rb} +0 -2
- data/generators/{templates/model_test.erb → model/templates/unit_test.rb} +2 -3
- data/generators/scaffold/USAGE +25 -0
- data/generators/scaffold/scaffold_generator.rb +53 -0
- data/generators/scaffold/templates/controller.rb +57 -0
- data/generators/scaffold/templates/fixtures.yml +7 -0
- data/generators/scaffold/templates/functional_test.rb +79 -0
- data/generators/scaffold/templates/layout.rhtml +11 -0
- data/generators/scaffold/templates/style.css +53 -0
- data/generators/scaffold/templates/view_edit.rhtml +7 -0
- data/generators/scaffold/templates/view_list.rhtml +24 -0
- data/generators/scaffold/templates/view_new.rhtml +6 -0
- data/generators/scaffold/templates/view_show.rhtml +8 -0
- data/helpers/{abstract_application.rb → application.rb} +1 -4
- data/helpers/test_helper.rb +4 -5
- data/lib/binding_of_caller.rb +81 -0
- data/lib/breakpoint.rb +526 -0
- data/lib/breakpoint_client.rb +167 -0
- data/lib/dispatcher.rb +43 -12
- data/lib/rails_generator.rb +175 -0
- data/lib/webrick_server.rb +48 -52
- metadata +49 -21
- data/gem_snapshot +0 -14
- data/generators/new_controller.rb +0 -43
- data/generators/new_crud.rb +0 -34
- data/generators/new_mailer.rb +0 -43
- data/generators/new_model.rb +0 -31
- data/generators/templates/controller.erb +0 -24
- data/generators/templates/controller_view.rhtml +0 -10
- data/generators/templates/mailer_fixture.rhtml +0 -4
- data/lib/generator.rb +0 -112
data/environments/test.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
ActiveRecord::Base.
|
4
|
-
Logger.new(File.dirname(__FILE__) + "/../../log/test.log")
|
5
|
-
|
6
|
-
ActiveRecord::Base.establish_connection(database_configurations["test"])
|
1
|
+
ActionController::Base.consider_all_requests_local = true
|
2
|
+
ActionController::Base.reload_dependencies = false
|
3
|
+
ActiveRecord::Base.reload_associations = false
|
data/fresh_rakefile
CHANGED
@@ -4,11 +4,11 @@ require 'rake/rdoctask'
|
|
4
4
|
|
5
5
|
$VERBOSE = nil
|
6
6
|
|
7
|
-
require File.dirname(__FILE__) + '/config/
|
7
|
+
require File.dirname(__FILE__) + '/config/environment'
|
8
8
|
require 'code_statistics'
|
9
9
|
|
10
10
|
desc "Run all the tests on a fresh test database"
|
11
|
-
task :default => [ :
|
11
|
+
task :default => [ :clone_development_structure_to_test, :test_units, :test_functional ]
|
12
12
|
|
13
13
|
desc "Generate API documentatio, show coding stats"
|
14
14
|
task :doc => [ :appdoc, :stats ]
|
@@ -43,6 +43,7 @@ Rake::RDocTask.new("apidoc") { |rdoc|
|
|
43
43
|
rdoc.title = "Rails Framework Documentation"
|
44
44
|
rdoc.options << '--line-numbers --inline-source'
|
45
45
|
rdoc.rdoc_files.include('README')
|
46
|
+
rdoc.rdoc_files.include('vendor/railties/lib/breakpoint.rb')
|
46
47
|
rdoc.rdoc_files.include('vendor/railties/CHANGELOG')
|
47
48
|
rdoc.rdoc_files.include('vendor/railties/MIT-LICENSE')
|
48
49
|
rdoc.rdoc_files.include('vendor/activerecord/README')
|
@@ -53,6 +54,9 @@ Rake::RDocTask.new("apidoc") { |rdoc|
|
|
53
54
|
rdoc.rdoc_files.include('vendor/actionpack/CHANGELOG')
|
54
55
|
rdoc.rdoc_files.include('vendor/actionpack/lib/action_controller/**/*.rb')
|
55
56
|
rdoc.rdoc_files.include('vendor/actionpack/lib/action_view/**/*.rb')
|
57
|
+
rdoc.rdoc_files.include('vendor/actionmailer/README')
|
58
|
+
rdoc.rdoc_files.include('vendor/actionmailer/CHANGELOG')
|
59
|
+
rdoc.rdoc_files.include('vendor/actionmailer/lib/action_mailer/base.rb')
|
56
60
|
}
|
57
61
|
|
58
62
|
desc "Report code statistics (KLOCs, etc) from the application"
|
@@ -66,36 +70,36 @@ task :stats do
|
|
66
70
|
).to_s
|
67
71
|
end
|
68
72
|
|
69
|
-
desc "Recreate the test databases from the
|
70
|
-
task :
|
71
|
-
if
|
72
|
-
ActiveRecord::Base.establish_connection(
|
73
|
+
desc "Recreate the test databases from the development structure"
|
74
|
+
task :clone_development_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
|
75
|
+
if ActiveRecord::Base.configurations["test"]["adapter"] == "mysql"
|
76
|
+
ActiveRecord::Base.establish_connection(:test)
|
73
77
|
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
|
74
|
-
IO.readlines("db/
|
78
|
+
IO.readlines("db/development_structure.sql").join.split("\n\n").each do |table|
|
75
79
|
ActiveRecord::Base.connection.execute(table)
|
76
80
|
end
|
77
|
-
elsif
|
78
|
-
`psql -U #{
|
81
|
+
elsif ActiveRecord::Base.configurations["test"]["adapter"] == "postgresql"
|
82
|
+
`psql -U #{ActiveRecord::Base.configurations["test"]["username"]} -f db/development_structure.sql #{ActiveRecord::Base.configurations["test"]["database"]}`
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
82
86
|
desc "Dump the database structure to a SQL file"
|
83
87
|
task :db_structure_dump do
|
84
|
-
if
|
85
|
-
ActiveRecord::Base.establish_connection(
|
86
|
-
File.open("db/
|
87
|
-
elsif
|
88
|
-
`pg_dump -U #{
|
88
|
+
if ActiveRecord::Base.configurations["development"]["adapter"] == "mysql"
|
89
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations["development"])
|
90
|
+
File.open("db/development_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
91
|
+
elsif ActiveRecord::Base.configurations["development"]["adapter"] == "postgresql"
|
92
|
+
`pg_dump -U #{ActiveRecord::Base.configurations["development"]["username"]} -s -f db/development_structure.sql #{ActiveRecord::Base.configurations["development"]["database"]}`
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
92
96
|
desc "Drop the test database and bring it back again"
|
93
97
|
task :purge_test_database do
|
94
|
-
if
|
95
|
-
ActiveRecord::Base.establish_connection(
|
96
|
-
ActiveRecord::Base.connection.recreate_database(
|
97
|
-
elsif
|
98
|
-
`dropdb -U #{
|
99
|
-
`createdb -U #{
|
98
|
+
if ActiveRecord::Base.configurations["test"]["adapter"] == "mysql"
|
99
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations["development"])
|
100
|
+
ActiveRecord::Base.connection.recreate_database(ActiveRecord::Base.configurations["test"]["database"])
|
101
|
+
elsif ActiveRecord::Base.configurations["test"]["adapter"] == "postgresql"
|
102
|
+
`dropdb -U #{ActiveRecord::Base.configurations["test"]["username"]} #{ActiveRecord::Base.configurations["test"]["database"]}`
|
103
|
+
`createdb -U #{ActiveRecord::Base.configurations["test"]["username"]} #{ActiveRecord::Base.configurations["test"]["database"]}`
|
100
104
|
end
|
101
|
-
end
|
105
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GENERATOR
|
2
|
+
controller - create controller and view stub files
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
generate controller ControllerName action [action ...]
|
6
|
+
|
7
|
+
DESCRIPTION
|
8
|
+
The controller generator takes the name of the new controller as the
|
9
|
+
first argument and a variable number of view names as subsequent arguments.
|
10
|
+
The controller name should be supplied without a "Controller" suffix. The
|
11
|
+
generator will add that itself.
|
12
|
+
|
13
|
+
Controller generates a controller file in app/controllers with a render
|
14
|
+
action for each of the view names passed, a test suite in test/functional
|
15
|
+
with one passing test case, and HTML stubs for each view in app/views
|
16
|
+
under a directory with the same name as the controller.
|
17
|
+
|
18
|
+
EXAMPLE
|
19
|
+
./script/generate controller Blog list display new edit
|
20
|
+
|
21
|
+
This will generate a BlogController class in
|
22
|
+
app/controllers/blog_controller.rb, a BlogHelper class in
|
23
|
+
app/helpers/blog_helper.rb and a BlogControllerTest in
|
24
|
+
test/functional/blog_controller_test.rb, and list.rhtml,
|
25
|
+
display.rhtml, new.rhtml, and edit.rhtml in app/views/blog.
|
26
|
+
|
27
|
+
The BlogController class will have list, display, new, and edit actions.
|
28
|
+
Each action will render the associated view by default.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails_generator'
|
2
|
+
|
3
|
+
class ControllerGenerator < Rails::Generator::Base
|
4
|
+
attr_reader :actions
|
5
|
+
|
6
|
+
def generate
|
7
|
+
@actions = args
|
8
|
+
|
9
|
+
# Controller class, functional test, and helper class.
|
10
|
+
template "controller.rb", "app/controllers/#{file_name}_controller.rb"
|
11
|
+
template "functional_test.rb", "test/functional/#{file_name}_controller_test.rb"
|
12
|
+
template "helper.rb", "app/helpers/#{file_name}_helper.rb"
|
13
|
+
|
14
|
+
# Create the views directory even if there are no actions.
|
15
|
+
FileUtils.mkdir_p "app/views/#{file_name}"
|
16
|
+
|
17
|
+
# Create a view for each action.
|
18
|
+
actions.each do |action|
|
19
|
+
template "view.rhtml", "app/views/#{file_name}/#{action}.rhtml", binding
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -10,7 +10,7 @@ class <%= class_name %>ControllerTest < Test::Unit::TestCase
|
|
10
10
|
@request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
|
11
11
|
end
|
12
12
|
|
13
|
-
# Replace this with your real tests
|
13
|
+
# Replace this with your real tests.
|
14
14
|
def test_truth
|
15
15
|
assert true
|
16
16
|
end
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
GENERATOR
|
2
|
+
mailer - create mailer and view stub files
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
generate mailer MailerName action [action ...]
|
6
|
+
|
7
|
+
DESCRIPTION
|
8
|
+
The mailer generator takes the name of the new mailer class as the
|
9
|
+
first argument and a variable number of mail action names as subsequent
|
10
|
+
arguments.
|
11
|
+
|
12
|
+
Mailer generates a class file in app/models with action methods for each
|
13
|
+
of the mail action names passed, a test suite in test/unit with a stub
|
14
|
+
test case and fixture per action, and template stubs for each action in
|
15
|
+
app/views under a directory with the same name as the class.
|
16
|
+
|
17
|
+
EXAMPLE
|
18
|
+
./script/generate mailer Notifications signup forgot_password invoice
|
19
|
+
|
20
|
+
This will generate a Notifications class in
|
21
|
+
app/models/notifications.rb, a NotificationsTest in
|
22
|
+
test/unit/notifications_test.rb, and signup, forgot_password, and invoice
|
23
|
+
in test/fixture/notification. It will also create signup.rhtml,
|
24
|
+
forgot_password.rhtml, and invoice.rhtml in app/views/notifications.
|
25
|
+
|
26
|
+
The Notifications class will have the following methods: signup,
|
27
|
+
forgot_password, and invoice.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails_generator'
|
2
|
+
|
3
|
+
class MailerGenerator < Rails::Generator::Base
|
4
|
+
attr_reader :actions
|
5
|
+
|
6
|
+
def generate
|
7
|
+
@actions = args
|
8
|
+
|
9
|
+
# Mailer class and unit test.
|
10
|
+
template "mailer.rb", "app/models/#{file_name}.rb"
|
11
|
+
template "unit_test.rb", "test/unit/#{file_name}_test.rb"
|
12
|
+
|
13
|
+
# Test fixtures directory.
|
14
|
+
FileUtils.mkdir_p "test/fixtures/#{table_name}"
|
15
|
+
|
16
|
+
# View template and fixture for each action.
|
17
|
+
args.each do |action|
|
18
|
+
template "view.rhtml", "app/views/#{file_name}/#{action}.rhtml", binding
|
19
|
+
template "fixture.rhtml", "test/fixtures/#{table_name}/#{action}", binding
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'action_mailer'
|
2
2
|
|
3
3
|
class <%= class_name %> < ActionMailer::Base
|
4
|
-
|
5
4
|
<% for action in actions -%>
|
5
|
+
|
6
6
|
def <%= action %>(sent_on = Time.now)
|
7
|
+
@subject = '<%= class_name %>#<%= action %>'
|
8
|
+
@body = {}
|
7
9
|
@recipients = ''
|
8
10
|
@from = ''
|
9
|
-
@subject = ''
|
10
|
-
@body = {}
|
11
11
|
@sent_on = sent_on
|
12
|
+
@headers = {}
|
12
13
|
end
|
13
|
-
|
14
14
|
<% end -%>
|
15
15
|
end
|
@@ -10,23 +10,15 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|
10
10
|
ActionMailer::Base.deliveries = []
|
11
11
|
|
12
12
|
@expected = TMail::Mail.new
|
13
|
-
@expected.to = 'test@localhost'
|
14
|
-
@expected.from = 'test@localhost'
|
15
|
-
@expected.subject = '<%= class_name %> test mail'
|
16
13
|
end
|
17
14
|
|
18
15
|
<% for action in actions -%>
|
19
16
|
def test_<%= action %>
|
17
|
+
@expected.subject = '<%= class_name %>#<%= action %>'
|
20
18
|
@expected.body = read_fixture('<%= action %>')
|
21
19
|
@expected.date = Time.now
|
22
20
|
|
23
|
-
|
24
|
-
assert_nothing_raised { created = <%= class_name %>.create_<%= action %>(@expected.date) }
|
25
|
-
assert_not_nil created
|
26
|
-
assert_equal expected.encoded, created.encoded
|
27
|
-
|
28
|
-
assert_nothing_raised { <%= class_name %>.deliver_<%= action %>(@expected.date) }
|
29
|
-
assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded
|
21
|
+
assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded
|
30
22
|
end
|
31
23
|
|
32
24
|
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
GENERATOR
|
2
|
+
model - create model stub files
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
generate model ModelName
|
6
|
+
|
7
|
+
DESCRIPTION
|
8
|
+
The model generator takes a model name and generates an empty model in
|
9
|
+
app/models, a test suite in test/unit with one passing test case, and a
|
10
|
+
fixtures YAML file in the test/fixtures directory.
|
11
|
+
|
12
|
+
EXAMPLE
|
13
|
+
./script/generate model Account
|
14
|
+
|
15
|
+
This will generate an Account class in app/models/account.rb, an
|
16
|
+
AccountTest in test/unit/account_test.rb, and the fixtures file
|
17
|
+
test/fixtures/account.yml.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rails_generator'
|
2
|
+
|
3
|
+
class ModelGenerator < Rails::Generator::Base
|
4
|
+
def generate
|
5
|
+
# Model class, unit test, and fixtures.
|
6
|
+
template "model.rb", "app/models/#{file_name}.rb"
|
7
|
+
template "unit_test.rb", "test/unit/#{file_name}_test.rb"
|
8
|
+
template "fixtures.yml", "test/fixtures/#{table_name}.yml"
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
require '<%= file_name %>'
|
3
2
|
|
4
3
|
class <%= class_name %>Test < Test::Unit::TestCase
|
5
4
|
fixtures :<%= table_name %>
|
6
5
|
|
7
|
-
# Replace this with your real tests
|
6
|
+
# Replace this with your real tests.
|
8
7
|
def test_truth
|
9
8
|
assert true
|
10
9
|
end
|
11
|
-
end
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
GENERATOR
|
2
|
+
scaffold - create a model and basic controller
|
3
|
+
|
4
|
+
SYNOPSIS
|
5
|
+
generate scaffold ModelName [action ...]
|
6
|
+
|
7
|
+
DESCRIPTION
|
8
|
+
The scaffold generator takes the name of the new model as the
|
9
|
+
first argument and an optional list of controller actions as the
|
10
|
+
subsequent arguments. Any actions with scaffolding code available
|
11
|
+
will be generated in your controller; others will be left as stubs.
|
12
|
+
|
13
|
+
The generated controller has the same code that "scaffold :model"
|
14
|
+
uses, so it's easy to migrate when you want to start customizing
|
15
|
+
your controller.
|
16
|
+
|
17
|
+
EXAMPLE
|
18
|
+
./script/generate scaffold Account debit credit
|
19
|
+
|
20
|
+
This will generate the Account model with unit tests and fixtures,
|
21
|
+
the AccountController controller with actions, views, and tests for
|
22
|
+
index, list, show, new, create, edit, update, and destroy.
|
23
|
+
|
24
|
+
Now create the accounts table in your database and browse to
|
25
|
+
http://localhost/account/ -- voila, you're on Rails!
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rails_generator'
|
2
|
+
|
3
|
+
class ScaffoldGenerator < Rails::Generator::Base
|
4
|
+
def generate
|
5
|
+
# Model.
|
6
|
+
generator('model').generate
|
7
|
+
|
8
|
+
# Fixtures.
|
9
|
+
template "fixtures.yml", "test/fixtures/#{table_name}.yml"
|
10
|
+
|
11
|
+
# Controller class, functional test, helper, and views.
|
12
|
+
template "controller.rb", "app/controllers/#{file_name}_controller.rb"
|
13
|
+
template "functional_test.rb", "test/functional/#{file_name}_controller_test.rb"
|
14
|
+
template "controller/helper.rb", "app/helpers/#{file_name}_helper.rb"
|
15
|
+
|
16
|
+
# Layout and stylesheet.
|
17
|
+
unless File.file?("app/views/layouts/scaffold.rhtml")
|
18
|
+
template "layout.rhtml", "app/views/layouts/scaffold.rhtml"
|
19
|
+
end
|
20
|
+
unless File.file?("public/stylesheets/scaffold.css")
|
21
|
+
template "style.css", "public/stylesheets/scaffold.css"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Scaffolded views.
|
25
|
+
scaffold_views.each do |action|
|
26
|
+
template "view_#{action}.rhtml", "app/views/#{file_name}/#{action}.rhtml"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Unscaffolded views.
|
30
|
+
unscaffolded_actions.each do |action|
|
31
|
+
template "controller/view.rhtml",
|
32
|
+
"app/views/#{file_name}/#{action}.rhtml",
|
33
|
+
binding
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
def scaffold_views
|
39
|
+
%w(list show new edit)
|
40
|
+
end
|
41
|
+
|
42
|
+
def scaffold_actions
|
43
|
+
scaffold_views + %w(index create update destroy)
|
44
|
+
end
|
45
|
+
|
46
|
+
def unscaffolded_actions
|
47
|
+
args - scaffold_actions
|
48
|
+
end
|
49
|
+
|
50
|
+
def suffix
|
51
|
+
"_#{singular_name}" if options[:suffix]
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class <%= class_name %>Controller < ApplicationController
|
2
|
+
layout 'scaffold'
|
3
|
+
|
4
|
+
<% unless suffix -%>
|
5
|
+
def index
|
6
|
+
list
|
7
|
+
render_action 'list'
|
8
|
+
end
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<% for action in unscaffolded_actions -%>
|
12
|
+
def <%= action %><%= suffix %>
|
13
|
+
end
|
14
|
+
|
15
|
+
<% end -%>
|
16
|
+
def list<%= suffix %>
|
17
|
+
@<%= plural_name %> = <%= class_name %>.find_all
|
18
|
+
end
|
19
|
+
|
20
|
+
def show<%= suffix %>
|
21
|
+
@<%= singular_name %> = <%= class_name %>.find(@params['id'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def new<%= suffix %>
|
25
|
+
@<%= singular_name %> = <%= class_name %>.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def create<%= suffix %>
|
29
|
+
@<%= singular_name %> = <%= class_name %>.new(@params['<%= singular_name %>'])
|
30
|
+
if @<%= singular_name %>.save
|
31
|
+
flash['notice'] = '<%= class_name %> was successfully created.'
|
32
|
+
redirect_to :action => 'list<%= suffix %>'
|
33
|
+
else
|
34
|
+
render_action 'new<%= suffix %>'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit<%= suffix %>
|
39
|
+
@<%= singular_name %> = <%= class_name %>.find(@params['id'])
|
40
|
+
end
|
41
|
+
|
42
|
+
def update
|
43
|
+
@<%= singular_name %> = <%= class_name %>.find(@params['<%= singular_name %>']['id'])
|
44
|
+
@<%= singular_name %>.attributes = @params['<%= singular_name %>']
|
45
|
+
if @<%= singular_name %>.save
|
46
|
+
flash['notice'] = '<%= class_name %> was successfully updated.'
|
47
|
+
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>.id
|
48
|
+
else
|
49
|
+
render_action 'edit<%= suffix %>'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy<%= suffix %>
|
54
|
+
<%= class_name %>.find(@params['id']).destroy
|
55
|
+
redirect_to :action => 'list<%= suffix %>'
|
56
|
+
end
|
57
|
+
end
|