has_many_polymorphs 2.11 → 2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +3 -1
  3. data/Manifest +43 -61
  4. data/README +30 -0
  5. data/TODO +0 -3
  6. data/generators/tagging/tagging_generator.rb +2 -0
  7. data/generators/tagging/templates/tag_test.rb +7 -2
  8. data/generators/tagging/templates/tagging.rb +2 -2
  9. data/generators/tagging/templates/tagging_extensions.rb +49 -2
  10. data/generators/tagging/templates/tagging_test.rb +32 -9
  11. data/generators/tagging/templates/tags.yml +2 -2
  12. data/has_many_polymorphs.gemspec +20 -13
  13. data/lib/has_many_polymorphs.rb +0 -1
  14. data/lib/has_many_polymorphs/autoload.rb +45 -37
  15. data/lib/has_many_polymorphs/class_methods.rb +2 -15
  16. data/lib/has_many_polymorphs/configuration.rb +2 -2
  17. data/lib/has_many_polymorphs/rake_task_redefine_task.rb +9 -1
  18. data/test/generator/tagging_generator_test.rb +42 -0
  19. data/test/integration/app/app/controllers/bones_controller.rb +5 -0
  20. data/test/integration/app/app/helpers/bones_helper.rb +2 -0
  21. data/test/integration/app/app/models/bone.rb +2 -0
  22. data/test/integration/app/app/models/double_sti_parent.rb +2 -0
  23. data/test/integration/app/app/models/double_sti_parent_relationship.rb +2 -0
  24. data/test/integration/app/app/models/organic_substance.rb +2 -0
  25. data/test/integration/app/app/models/single_sti_parent.rb +4 -0
  26. data/test/integration/app/app/models/single_sti_parent_relationship.rb +4 -0
  27. data/test/integration/app/app/models/stick.rb +2 -0
  28. data/test/integration/app/app/models/stone.rb +2 -0
  29. data/test/integration/app/app/views/bones/index.rhtml +5 -0
  30. data/test/integration/app/config/boot.rb +97 -32
  31. data/test/integration/app/config/database.yml +8 -12
  32. data/test/integration/app/config/environment.rb +9 -3
  33. data/test/integration/app/config/environment.rb.canonical +19 -0
  34. data/test/integration/app/config/environments/development.rb +6 -5
  35. data/test/integration/app/db/migrate/001_create_sticks.rb +11 -0
  36. data/test/integration/app/db/migrate/002_create_stones.rb +11 -0
  37. data/test/integration/app/db/migrate/003_create_organic_substances.rb +11 -0
  38. data/test/integration/app/db/migrate/004_create_bones.rb +8 -0
  39. data/test/integration/app/db/migrate/005_create_single_sti_parents.rb +11 -0
  40. data/test/integration/app/db/migrate/006_create_double_sti_parents.rb +11 -0
  41. data/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +13 -0
  42. data/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +14 -0
  43. data/test/integration/app/db/migrate/009_create_library_model.rb +11 -0
  44. data/test/integration/app/db/schema.rb +21 -121
  45. data/test/integration/app/hmp_development +0 -0
  46. data/test/integration/app/lib/library_model.rb +2 -0
  47. data/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +7 -0
  48. data/test/integration/app/test/fixtures/double_sti_parents.yml +7 -0
  49. data/test/integration/app/test/fixtures/organic_substances.yml +5 -0
  50. data/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +7 -0
  51. data/test/integration/app/test/fixtures/single_sti_parents.yml +7 -0
  52. data/test/integration/app/test/fixtures/sticks.yml +7 -0
  53. data/test/integration/app/test/fixtures/stones.yml +7 -0
  54. data/test/integration/app/test/{unit/user_test.rb → functional/bones_controller_test.rb} +1 -3
  55. data/test/integration/app/test/test_helper.rb +1 -21
  56. data/test/integration/app/test/unit/{state_test.rb → bone_test.rb} +1 -3
  57. data/test/integration/app/test/unit/{seller_test.rb → double_sti_parent_relationship_test.rb} +1 -3
  58. data/test/integration/app/test/unit/{address_test.rb → double_sti_parent_test.rb} +1 -3
  59. data/test/integration/app/test/unit/organic_substance_test.rb +8 -0
  60. data/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +8 -0
  61. data/test/integration/app/test/unit/single_sti_parent_test.rb +8 -0
  62. data/test/integration/app/test/unit/stick_test.rb +8 -0
  63. data/test/integration/app/test/unit/stone_test.rb +8 -0
  64. data/test/integration/server_test.rb +43 -0
  65. data/test/patches/symlinked_plugins_1.2.6.diff +46 -0
  66. data/test/setup.rb +6 -2
  67. data/test/test_helper.rb +32 -16
  68. data/test/unit/{polymorph_test.rb → has_many_polymorphs_test.rb} +16 -16
  69. metadata +49 -65
  70. metadata.gz.sig +0 -0
  71. data/generators/commenting/commenting_generator.rb +0 -94
  72. data/generators/commenting/templates/comment.rb +0 -33
  73. data/generators/commenting/templates/comment_test.rb +0 -12
  74. data/generators/commenting/templates/commenting.rb +0 -13
  75. data/generators/commenting/templates/commenting_extensions.rb +0 -30
  76. data/generators/commenting/templates/commenting_test.rb +0 -30
  77. data/generators/commenting/templates/commentings.yml +0 -23
  78. data/generators/commenting/templates/comments.yml +0 -13
  79. data/generators/commenting/templates/migration.rb +0 -28
  80. data/lib/has_many_polymorphs/dependencies.rb +0 -41
  81. data/test/integration/app/app/controllers/addresses_controller.rb +0 -85
  82. data/test/integration/app/app/controllers/sellers_controller.rb +0 -85
  83. data/test/integration/app/app/controllers/states_controller.rb +0 -85
  84. data/test/integration/app/app/controllers/users_controller.rb +0 -85
  85. data/test/integration/app/app/models/address.rb +0 -4
  86. data/test/integration/app/app/models/citation.rb +0 -3
  87. data/test/integration/app/app/models/citations_item.rb +0 -4
  88. data/test/integration/app/app/models/seller.rb +0 -4
  89. data/test/integration/app/app/models/state.rb +0 -3
  90. data/test/integration/app/app/models/user.rb +0 -4
  91. data/test/integration/app/db/migrate/001_create_users.rb +0 -16
  92. data/test/integration/app/db/migrate/002_create_sellers.rb +0 -14
  93. data/test/integration/app/db/migrate/003_create_addresses.rb +0 -19
  94. data/test/integration/app/db/migrate/004_create_states.rb +0 -12
  95. data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +0 -9
  96. data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +0 -9
  97. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +0 -11
  98. data/test/integration/app/db/migrate/008_create_citations.rb +0 -12
  99. data/test/integration/app/db/migrate/009_create_citations_items.rb +0 -14
  100. data/test/integration/app/generated_models/aquatic_fish.rb +0 -109
  101. data/test/integration/app/generated_models/aquatic_pupils_whale.rb +0 -13
  102. data/test/integration/app/generated_models/aquatic_whale.rb +0 -42
  103. data/test/integration/app/generated_models/beautiful_fight_relationship.rb +0 -25
  104. data/test/integration/app/generated_models/citation.rb +0 -40
  105. data/test/integration/app/generated_models/citations_item.rb +0 -12
  106. data/test/integration/app/generated_models/dog.rb +0 -183
  107. data/test/integration/app/generated_models/eaters_foodstuff.rb +0 -13
  108. data/test/integration/app/generated_models/frog.rb +0 -78
  109. data/test/integration/app/generated_models/kitten.rb +0 -161
  110. data/test/integration/app/generated_models/parentship.rb +0 -14
  111. data/test/integration/app/generated_models/person.rb +0 -53
  112. data/test/integration/app/generated_models/petfood.rb +0 -125
  113. data/test/integration/app/generated_models/polymorph_test_some_model.rb +0 -25
  114. data/test/integration/app/generated_models/seller.rb +0 -30
  115. data/test/integration/app/generated_models/tabby.rb +0 -26
  116. data/test/integration/app/generated_models/user.rb +0 -34
  117. data/test/integration/app/generated_models/wild_boar.rb +0 -87
  118. data/test/integration/app/test/fixtures/addresses.yml +0 -13
  119. data/test/integration/app/test/fixtures/citations.yml +0 -9
  120. data/test/integration/app/test/fixtures/citations_items.yml +0 -9
  121. data/test/integration/app/test/fixtures/sellers.yml +0 -10
  122. data/test/integration/app/test/fixtures/states.yml +0 -216
  123. data/test/integration/app/test/fixtures/users.yml +0 -11
  124. data/test/integration/app/test/unit/citation_test.rb +0 -10
  125. data/test/integration/app/test/unit/citations_item_test.rb +0 -10
  126. data/test/test_all.rb +0 -16
metadata.gz.sig CHANGED
Binary file
@@ -1,94 +0,0 @@
1
-
2
- class CommentingGenerator < Rails::Generator::NamedBase
3
- default_options :skip_migration => false
4
- default_options :self_referential => false
5
- attr_reader :parent_association_name
6
- attr_reader :commentable_models
7
-
8
- def initialize(runtime_args, runtime_options = {})
9
- @parent_association_name = (runtime_args.include?("--self-referential") ? "commenter" : "comment")
10
- @commentable_models = runtime_args.reject{|opt| opt =~ /^--/}.map do |commentable|
11
- ":" + commentable.underscore.pluralize
12
- end
13
- @commentable_models += [":comments"] if runtime_args.include?("--self-referential")
14
- @commentable_models.uniq!
15
-
16
- verify @commentable_models
17
- hacks
18
- runtime_args.unshift("placeholder")
19
- super
20
- end
21
-
22
- def verify models
23
- puts "** Warning: only one commentable model specified; tests may not run properly." if models.size < 2
24
- models.each do |model|
25
- model = model[1..-1].classify
26
- next if model == "Comment" # don't load ourselves when --self-referential is used
27
- self.class.const_get(model) rescue puts "** Error: model #{model[1..-1].classify} could not be loaded." or exit
28
- end
29
- end
30
-
31
- def hacks
32
- # add the extension require in environment.rb
33
- phrase = "require 'commenting_extensions'"
34
- filename = "#{RAILS_ROOT}/config/environment.rb"
35
- unless (open(filename) do |file|
36
- file.grep(/#{Regexp.escape phrase}/).any?
37
- end)
38
- open(filename, 'a+') do |file|
39
- file.puts "\n" + phrase + "\n"
40
- end
41
- end
42
- end
43
-
44
- def manifest
45
- record do |m|
46
- m.class_collisions class_path, class_name, "#{class_name}Test"
47
-
48
- m.directory File.join('app/models', class_path)
49
- m.directory File.join('test/unit', class_path)
50
- m.directory File.join('test/fixtures', class_path)
51
- m.directory File.join('test/fixtures', class_path)
52
- m.directory File.join('lib')
53
-
54
- m.template 'comment.rb', File.join('app/models', class_path, "comment.rb")
55
- m.template 'comment_test.rb', File.join('test/unit', class_path, "comment_test.rb")
56
- m.template 'comments.yml', File.join('test/fixtures', class_path, "comments.yml")
57
-
58
- m.template 'commenting.rb', File.join('app/models', class_path, "commenting.rb")
59
- m.template 'commenting_test.rb', File.join('test/unit', class_path, "commenting_test.rb")
60
- m.template 'commentings.yml', File.join('test/fixtures', class_path, "commentings.yml")
61
-
62
- m.template 'commenting_extensions.rb', File.join('lib', 'commenting_extensions.rb')
63
-
64
- unless options[:skip_migration]
65
- m.migration_template 'migration.rb', 'db/migrate',
66
- :migration_file_name => "create_comments_and_commentings"
67
- end
68
-
69
- end
70
- end
71
-
72
- protected
73
- def banner
74
- "Usage: #{$0} generate commenting [CommentableModelA CommentableModelB ...]"
75
- end
76
-
77
- def add_options!(opt)
78
- opt.separator ''
79
- opt.separator 'Options:'
80
- opt.on("--skip-migration",
81
- "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
82
- opt.on("--self-referential",
83
- "Allow comments to comment themselves.") { |v| options[:self_referential] = v }
84
- end
85
-
86
- # Useful for generating tests/fixtures
87
- def model_one
88
- commentable_models[0][1..-1].classify
89
- end
90
-
91
- def model_two
92
- commentable_models[1][1..-1].classify rescue model_one
93
- end
94
- end
@@ -1,33 +0,0 @@
1
-
2
- # The Comment model. This model is automatically generated and added to your app if you run the commenting generator.
3
-
4
- class Comment < ActiveRecord::Base
5
-
6
- # If database speed becomes an issue, you could remove these validations and rescue the ActiveRecord database constraint errors instead.
7
- validates_presence_of :name, :email, :body
8
- validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
9
-
10
- after_validation :prepend_url
11
-
12
- # Set up the polymorphic relationship.
13
- has_many_polymorphs :commentables,
14
- :from => [<%= commentable_models.join(", ") %>],
15
- :through => :commentings,
16
- :dependent => :destroy,
17
- <% if options[:self_referential] -%> :as => :<%= parent_association_name -%>,
18
- <% end -%>
19
- :parent_extend => proc {
20
- }
21
-
22
- # Tag::Error class. Raised by ActiveRecord::Base::TaggingExtensions if something goes wrong.
23
- class Error < StandardError
24
- end
25
-
26
- protected
27
- def prepend_url
28
- return if self[:url].blank?
29
- if self[:url] !~ /^http(s):\/\//i
30
- self.url = 'http://' + self[:url]
31
- end
32
- end
33
- end
@@ -1,12 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class CommentTest < Test::Unit::TestCase
4
- fixtures :comments, :commentings, <%= commentable_models[0..1].join(", ") -%>
5
-
6
- def test_to_s
7
- assert_equal "no1@nowhere.com", <%= model_two -%>.find(2).comments.first.email
8
- assert_equal "http://letrails.cn", <%= model_two -%>.find(2).comments.last.url
9
- assert_equal "http://fr.ivolo.us", <%= model_two -%>.find(2).comments.first.url
10
- end
11
-
12
- end
@@ -1,13 +0,0 @@
1
-
2
- # The Commenting join model. This model is automatically generated and added to your app if you run the commenting generator.
3
-
4
- class Commenting < ActiveRecord::Base
5
-
6
- belongs_to :<%= parent_association_name -%><%= ", :foreign_key => \"#{parent_association_name}_id\", :class_name => \"Comment\"" if options[:self_referential] %>
7
- belongs_to :commentable, :polymorphic => true
8
-
9
- # This callback makes sure that an orphaned <tt>Comment</tt> is deleted if it no longer tags anything.
10
- def before_destroy
11
- <%= parent_association_name -%>.destroy_without_callbacks if <%= parent_association_name -%> and <%= parent_association_name -%>.commentings.count == 1
12
- end
13
- end
@@ -1,30 +0,0 @@
1
- class ActiveRecord::Base
2
- module CommentingExtensions
3
-
4
- def comment_count
5
- commentable?
6
- self.comments.size
7
- end
8
-
9
- def comment_with(attributes)
10
- commentable?(true)
11
- begin
12
- comment = Comment.create(attributes)
13
- raise Comment::Error, "Comment could not be saved with" if comment.new_record?
14
- comment.commentables << self
15
- rescue
16
- end
17
- end
18
-
19
- private
20
- def commentable?(should_raise = false) #:nodoc:
21
- unless flag = respond_to?(:<%= parent_association_name -%>s)
22
- raise "#{self.class} is not a commentable model" if should_raise
23
- end
24
- flag
25
- end
26
- end
27
-
28
- include CommentingExtensions
29
- end
30
-
@@ -1,30 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class CommentingTest < Test::Unit::TestCase
4
- fixtures :commentings, :comments, <%= commentable_models[0..1].join(", ") -%>
5
-
6
- def setup
7
- @obj1 = <%= model_two %>.find(1)
8
- @obj2 = <%= model_two %>.find(2)
9
- <% if commentable_models.size > 1 -%>
10
- @obj3 = <%= model_one -%>.find(1)
11
- <% end -%>
12
- @comment1 = Comment.find(1)
13
- @comment2 = Comment.find(2)
14
- @commenting1 = Commenting.find(1)
15
- end
16
-
17
- def test_commentable
18
- assert_raises(RuntimeError) do
19
- @commenting1.send(:commentable?, true)
20
- end
21
- assert !@commenting1.send(:commentable?)
22
- <% if commentable_models.size > 1 -%>
23
- assert @obj3.send(:commentable?)
24
- <% end -%>
25
- <% if options[:self_referential] -%>
26
- assert @comment1.send(:commentable?)
27
- <% end -%>
28
- end
29
-
30
- end
@@ -1,23 +0,0 @@
1
- ---
2
- <% if commentable_models.size > 1 -%>
3
- commentings_003:
4
- <%= parent_association_name -%>_id: "2"
5
- id: "3"
6
- commentable_type: <%= model_one %>
7
- commentable_id: "1"
8
- <% end -%>
9
- commentings_004:
10
- <%= parent_association_name -%>_id: "2"
11
- id: "4"
12
- commentable_type: <%= model_two %>
13
- commentable_id: "2"
14
- commentings_001:
15
- <%= parent_association_name -%>_id: "1"
16
- id: "1"
17
- commentable_type: <%= model_two %>
18
- commentable_id: "1"
19
- commentings_002:
20
- <%= parent_association_name -%>_id: "1"
21
- id: "2"
22
- commentable_type: <%= model_two %>
23
- commentable_id: "2"
@@ -1,13 +0,0 @@
1
- ---
2
- comments_001:
3
- id: "1"
4
- name: frivolous
5
- email: no1@nowhere.com
6
- url: http://fr.ivolo.us
7
- body: this plugin rocks!
8
- tags_002:
9
- id: "2"
10
- name: yuanyiz
11
- email: no1@nowhere.com
12
- url: http://letrails.cn
13
- body: this plugin has saved my life
@@ -1,28 +0,0 @@
1
-
2
- # A migration to add tables for Comment and Commenting. This file is automatically generated and added to your app if you run the commenting generator.
3
-
4
- class CreateCommentsAndCommentings < ActiveRecord::Migration
5
-
6
- # Add the new tables.
7
- def self.up
8
- create_table :comments do |t|
9
- t.column :name, :string, :null => false
10
- t.column :url, :string
11
- t.column :email, :string
12
- t.column :body, :text
13
- end
14
-
15
- create_table :commentings do |t|
16
- t.column :<%= parent_association_name -%>_id, :integer, :null => false
17
- t.column :commentable_id, :integer, :null => false
18
- t.column :commentable_type, :string, :null => false
19
- end
20
- end
21
-
22
- # Remove the tables.
23
- def self.down
24
- drop_table :comments
25
- drop_table :commentings
26
- end
27
-
28
- end
@@ -1,41 +0,0 @@
1
-
2
- =begin rdoc
3
- Adds a minimal dependency injection framework so that owners of polymorphic relationships reload after their children, reinjecting the child helper methods.
4
-
5
- Overrides Dependencies#<tt>new_constants_in</tt>.
6
- =end
7
-
8
- module Dependencies
9
-
10
- mattr_accessor :injection_graph
11
- self.injection_graph = Hash.new([])
12
-
13
- # Add a dependency for this target.
14
- def inject_dependency(target, *requirements)
15
- target, requirements = target.to_s, requirements.map(&:to_s)
16
- injection_graph[target] = ((injection_graph[target] + requirements).uniq - [target])
17
- requirements.each {|requirement| mark_for_unload requirement }
18
- _logger_debug "injection graph: #{injection_graph.inspect}" if Dependencies.log_activity
19
- end
20
-
21
- # Make sure any dependent constants of the constants added by <tt>yield</tt> are reloaded.
22
- def new_constants_in_with_injection(*descs, &block) # chain
23
-
24
- if Dependencies.log_activity
25
- _logger_debug "autoloaded constants: #{autoloaded_constants.inspect}"
26
- _logger_debug "explicitly unloadable constants: #{explicitly_unloadable_constants.inspect}"
27
- end
28
-
29
- returning(new_constants_in_without_injection(*descs, &block)) do |found|
30
- _logger_debug "new constants: #{found.inspect}" if Dependencies.log_activity and found.any?
31
- found.each do |constant|
32
- injection_graph[constant].each do |requirement|
33
- requirement.constantize
34
- _logger_debug "constantized #{requirement}" if Dependencies.log_activity
35
- end
36
- end
37
- end
38
- end
39
- alias_method_chain :new_constants_in, :injection
40
-
41
- end
@@ -1,85 +0,0 @@
1
- class AddressesController < ApplicationController
2
- # GET /addresses
3
- # GET /addresses.xml
4
- def index
5
- @addresses = Address.find(:all)
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.xml { render :xml => @addresses }
10
- end
11
- end
12
-
13
- # GET /addresses/1
14
- # GET /addresses/1.xml
15
- def show
16
- @address = Address.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.xml { render :xml => @address }
21
- end
22
- end
23
-
24
- # GET /addresses/new
25
- # GET /addresses/new.xml
26
- def new
27
- @address = Address.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.xml { render :xml => @address }
32
- end
33
- end
34
-
35
- # GET /addresses/1/edit
36
- def edit
37
- @address = Address.find(params[:id])
38
- end
39
-
40
- # POST /addresses
41
- # POST /addresses.xml
42
- def create
43
- @address = Address.new(params[:address])
44
-
45
- respond_to do |format|
46
- if @address.save
47
- flash[:notice] = 'Address was successfully created.'
48
- format.html { redirect_to(@address) }
49
- format.xml { render :xml => @address, :status => :created, :location => @address }
50
- else
51
- format.html { render :action => "new" }
52
- format.xml { render :xml => @address.errors, :status => :unprocessable_entity }
53
- end
54
- end
55
- end
56
-
57
- # PUT /addresses/1
58
- # PUT /addresses/1.xml
59
- def update
60
- @address = Address.find(params[:id])
61
-
62
- respond_to do |format|
63
- if @address.update_attributes(params[:address])
64
- flash[:notice] = 'Address was successfully updated.'
65
- format.html { redirect_to(@address) }
66
- format.xml { head :ok }
67
- else
68
- format.html { render :action => "edit" }
69
- format.xml { render :xml => @address.errors, :status => :unprocessable_entity }
70
- end
71
- end
72
- end
73
-
74
- # DELETE /addresses/1
75
- # DELETE /addresses/1.xml
76
- def destroy
77
- @address = Address.find(params[:id])
78
- @address.destroy
79
-
80
- respond_to do |format|
81
- format.html { redirect_to(addresses_url) }
82
- format.xml { head :ok }
83
- end
84
- end
85
- end
@@ -1,85 +0,0 @@
1
- class SellersController < ApplicationController
2
- # GET /sellers
3
- # GET /sellers.xml
4
- def index
5
- @sellers = Seller.find(:all)
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.xml { render :xml => @sellers }
10
- end
11
- end
12
-
13
- # GET /sellers/1
14
- # GET /sellers/1.xml
15
- def show
16
- @seller = Seller.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.xml { render :xml => @seller }
21
- end
22
- end
23
-
24
- # GET /sellers/new
25
- # GET /sellers/new.xml
26
- def new
27
- @seller = Seller.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.xml { render :xml => @seller }
32
- end
33
- end
34
-
35
- # GET /sellers/1/edit
36
- def edit
37
- @seller = Seller.find(params[:id])
38
- end
39
-
40
- # POST /sellers
41
- # POST /sellers.xml
42
- def create
43
- @seller = Seller.new(params[:seller])
44
-
45
- respond_to do |format|
46
- if @seller.save
47
- flash[:notice] = 'Seller was successfully created.'
48
- format.html { redirect_to(@seller) }
49
- format.xml { render :xml => @seller, :status => :created, :location => @seller }
50
- else
51
- format.html { render :action => "new" }
52
- format.xml { render :xml => @seller.errors, :status => :unprocessable_entity }
53
- end
54
- end
55
- end
56
-
57
- # PUT /sellers/1
58
- # PUT /sellers/1.xml
59
- def update
60
- @seller = Seller.find(params[:id])
61
-
62
- respond_to do |format|
63
- if @seller.update_attributes(params[:seller])
64
- flash[:notice] = 'Seller was successfully updated.'
65
- format.html { redirect_to(@seller) }
66
- format.xml { head :ok }
67
- else
68
- format.html { render :action => "edit" }
69
- format.xml { render :xml => @seller.errors, :status => :unprocessable_entity }
70
- end
71
- end
72
- end
73
-
74
- # DELETE /sellers/1
75
- # DELETE /sellers/1.xml
76
- def destroy
77
- @seller = Seller.find(params[:id])
78
- @seller.destroy
79
-
80
- respond_to do |format|
81
- format.html { redirect_to(sellers_url) }
82
- format.xml { head :ok }
83
- end
84
- end
85
- end