enform 0.0.1

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.
Files changed (96) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +20 -0
  3. data/README +0 -0
  4. data/Rakefile +32 -0
  5. data/enform.gemspec +17 -0
  6. data/lib/enform.rb +5 -0
  7. data/lib/enform/enform_railtie.rb +7 -0
  8. data/lib/enform/rails/tasks/enform.rake +0 -0
  9. data/lib/enform/version.rb +3 -0
  10. data/lib/generators/enform_generator.rb +60 -0
  11. data/lib/generators/templates/controllers/controller.rb +83 -0
  12. data/lib/generators/templates/views/haml/_form.html.haml +27 -0
  13. data/lib/generators/templates/views/haml/_object.haml +10 -0
  14. data/lib/generators/templates/views/haml/edit.html.haml +8 -0
  15. data/lib/generators/templates/views/haml/new.html.haml +8 -0
  16. data/spec/dummy/Rakefile +7 -0
  17. data/spec/dummy/app/assets/javascripts/application.js +10 -0
  18. data/spec/dummy/app/assets/javascripts/monkeys.js +2 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  20. data/spec/dummy/app/assets/stylesheets/monkeys.css +4 -0
  21. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  23. data/spec/dummy/app/controllers/monkeys_controller.rb +83 -0
  24. data/spec/dummy/app/controllers/posts_controller.rb +83 -0
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/helpers/monkeys_helper.rb +2 -0
  27. data/spec/dummy/app/mailers/.gitkeep +0 -0
  28. data/spec/dummy/app/models/.gitkeep +0 -0
  29. data/spec/dummy/app/models/author.rb +4 -0
  30. data/spec/dummy/app/models/category.rb +3 -0
  31. data/spec/dummy/app/models/comment.rb +3 -0
  32. data/spec/dummy/app/models/monkey.rb +2 -0
  33. data/spec/dummy/app/models/post.rb +7 -0
  34. data/spec/dummy/app/models/tag_line.rb +3 -0
  35. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  36. data/spec/dummy/app/views/monkeys/_form.html.erb +21 -0
  37. data/spec/dummy/app/views/monkeys/edit.html.erb +6 -0
  38. data/spec/dummy/app/views/monkeys/index.html.erb +23 -0
  39. data/spec/dummy/app/views/monkeys/new.html.erb +5 -0
  40. data/spec/dummy/app/views/monkeys/show.html.erb +10 -0
  41. data/spec/dummy/app/views/posts/_comment.haml +5 -0
  42. data/spec/dummy/app/views/posts/_comment_fields.haml +6 -0
  43. data/spec/dummy/app/views/posts/_form.html.haml +18 -0
  44. data/spec/dummy/app/views/posts/edit.html.haml +8 -0
  45. data/spec/dummy/app/views/posts/new.html.haml +8 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/config/application.rb +45 -0
  48. data/spec/dummy/config/boot.rb +10 -0
  49. data/spec/dummy/config/database.yml +25 -0
  50. data/spec/dummy/config/environment.rb +5 -0
  51. data/spec/dummy/config/environments/development.rb +30 -0
  52. data/spec/dummy/config/environments/production.rb +60 -0
  53. data/spec/dummy/config/environments/test.rb +42 -0
  54. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/dummy/config/initializers/inflections.rb +10 -0
  56. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  57. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  58. data/spec/dummy/config/initializers/session_store.rb +8 -0
  59. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  60. data/spec/dummy/config/locales/en.yml +5 -0
  61. data/spec/dummy/config/routes.rb +61 -0
  62. data/spec/dummy/db/development.sqlite3 +0 -0
  63. data/spec/dummy/db/migrate/20111025035303_create_posts.rb +10 -0
  64. data/spec/dummy/db/migrate/20111025035331_create_comments.rb +12 -0
  65. data/spec/dummy/db/migrate/20111025042155_create_categories.rb +11 -0
  66. data/spec/dummy/db/migrate/20111025042312_create_authors.rb +10 -0
  67. data/spec/dummy/db/migrate/20111025042701_create_tag_lines.rb +11 -0
  68. data/spec/dummy/db/migrate/20111025061520_create_monkeys.rb +9 -0
  69. data/spec/dummy/db/schema.rb +58 -0
  70. data/spec/dummy/db/test.sqlite3 +0 -0
  71. data/spec/dummy/lib/assets/.gitkeep +0 -0
  72. data/spec/dummy/log/.gitkeep +0 -0
  73. data/spec/dummy/log/development.log +1179 -0
  74. data/spec/dummy/log/test.log +0 -0
  75. data/spec/dummy/public/404.html +26 -0
  76. data/spec/dummy/public/422.html +26 -0
  77. data/spec/dummy/public/500.html +26 -0
  78. data/spec/dummy/public/favicon.ico +0 -0
  79. data/spec/dummy/script/rails +6 -0
  80. data/spec/dummy/test/fixtures/authors.yml +7 -0
  81. data/spec/dummy/test/fixtures/categories.yml +9 -0
  82. data/spec/dummy/test/fixtures/comments.yml +11 -0
  83. data/spec/dummy/test/fixtures/monkeys.yml +7 -0
  84. data/spec/dummy/test/fixtures/posts.yml +9 -0
  85. data/spec/dummy/test/fixtures/tag_lines.yml +9 -0
  86. data/spec/dummy/test/functional/monkeys_controller_test.rb +49 -0
  87. data/spec/dummy/test/unit/author_test.rb +7 -0
  88. data/spec/dummy/test/unit/category_test.rb +7 -0
  89. data/spec/dummy/test/unit/comment_test.rb +7 -0
  90. data/spec/dummy/test/unit/helpers/monkeys_helper_test.rb +4 -0
  91. data/spec/dummy/test/unit/monkey_test.rb +7 -0
  92. data/spec/dummy/test/unit/post_test.rb +7 -0
  93. data/spec/dummy/test/unit/tag_line_test.rb +7 -0
  94. data/spec/enform_spec.rb +5 -0
  95. data/spec/spec_helper.rb +17 -0
  96. metadata +142 -0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rails'
5
+ gem 'haml-rails'
6
+ gem 'jquery-rails'
7
+ gem 'formtastic'
8
+ gem 'cocoon'
9
+ gem 'ruby-debug19', :require => 'ruby-debug'
10
+ gem 'rspec'
11
+ gem 'rake'
12
+ gem 'sqlite3'
13
+ group :assets do
14
+ gem 'coffee-script'
15
+ gem 'compass'
16
+ gem 'sass-rails'
17
+ gem 'uglifier'
18
+ #gem 'sprockets'
19
+ end
20
+
data/README ADDED
File without changes
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Enform'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rspec/core/rake_task'
28
+
29
+ RSpec::Core::RakeTask.new('spec')
30
+
31
+ # If you want to make this the default task
32
+ task :default => :spec
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/enform/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Christian Trosclair"]
6
+ gem.email = ["christian.trosclair@gmail.com"]
7
+ gem.description = %q{Create forms for your existing models!}
8
+ gem.summary = %q{Makes some assupmtions right now for your setup, will be more modular later on}
9
+ gem.homepage = "https://github.com/xn/enform"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "enform"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Enform::VERSION
17
+ end
@@ -0,0 +1,5 @@
1
+ require "enform/version"
2
+ require 'enform/enform_railtie.rb' if defined?(Rails)
3
+ module Enform
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,7 @@
1
+ module Enform
2
+ class EnformRailtie < ::Rails::Railtie
3
+ rake_tasks do
4
+ #load "enform/rails/tasks/enform.rake"
5
+ end
6
+ end
7
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ module Enform
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,60 @@
1
+ class EnformGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+ no_tasks { attr_accessor :model_name, :klass }
4
+ argument :model_name, :type => :string, :required => false, :banner => 'ModelName'
5
+
6
+ desc "Generate a form from an existing model"
7
+ def create_form_file
8
+ self.klass = model_name.constantize
9
+ template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{klass.table_name}/_form.html.#{view_language}"
10
+ have_manies.each do |hs_mny|
11
+ @hm = hs_mny
12
+ template "views/#{view_language}/_object.#{view_language}", "app/views/#{klass.table_name}/_#{@hm.name.to_s.singularize}_fields.#{view_language}"
13
+ end
14
+ template "views/#{view_language}/new.html.#{view_language}", "app/views/#{klass.table_name}/new.html.#{view_language}"
15
+ template "views/#{view_language}/edit.html.#{view_language}", "app/views/#{klass.table_name}/edit.html.#{view_language}"
16
+ template "controllers/controller.rb", "app/controllers/#{klass.table_name}_controller.rb"
17
+ end
18
+
19
+ private
20
+
21
+ def view_language
22
+ "haml"
23
+ end
24
+
25
+ def model_attributes
26
+ klass.new.attributes
27
+ end
28
+
29
+ def associations
30
+ klass.reflect_on_all_associations
31
+ end
32
+
33
+ def have_ones
34
+ klass.reflect_on_all_associations(:has_one)
35
+ end
36
+
37
+ def have_manies
38
+ klass.reflect_on_all_associations(:has_many)
39
+ end
40
+
41
+ def belong_tos
42
+ klass.reflect_on_all_associations(:belongs_to)
43
+ end
44
+
45
+ def attributes_for(assoc)
46
+ assoc.active_record.new.attributes
47
+ end
48
+
49
+ def have_ones_for(assoc)
50
+ assoc.reflect_on_all_associations(:has_one)
51
+ end
52
+
53
+ def have_manies_for(assoc)
54
+ assoc.reflect_on_all_associations(:has_many)
55
+ end
56
+
57
+ def belong_tos_for(assoc)
58
+ assoc.reflect_on_all_associations(:belongs_to)
59
+ end
60
+ end
@@ -0,0 +1,83 @@
1
+ class <%= model_name.pluralize %>Controller < ApplicationController
2
+ # GET /<%= klass.table_name %>
3
+ # GET /<%= klass.table_name %>.json
4
+ def index
5
+ @<%= klass.table_name %> = <%= model_name %>.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @<%= klass.table_name %> }
10
+ end
11
+ end
12
+
13
+ # GET /<%= klass.table_name %>/1
14
+ # GET /<%= klass.table_name %>/1.json
15
+ def show
16
+ @<%= klass.table_name.singularize %> = <%= model_name %>.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render json: @<%= klass.table_name.singularize %> }
21
+ end
22
+ end
23
+
24
+ # GET /<%= klass.table_name %>/new
25
+ # GET /<%= klass.table_name %>/new.json
26
+ def new
27
+ @<%= klass.table_name.singularize %> = <%= model_name %>.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render json: @<%= klass.table_name.singularize %> }
32
+ end
33
+ end
34
+
35
+ # GET /<%= klass.table_name %>/1/edit
36
+ def edit
37
+ @<%= klass.table_name.singularize %> = <%= model_name %>.find(params[:id])
38
+ end
39
+
40
+ # POST /<%= klass.table_name %>
41
+ # POST /<%= klass.table_name %>.json
42
+ def create
43
+ @<%= klass.table_name.singularize %> = <%= model_name %>.new(params[:<%= klass.table_name.singularize %>])
44
+
45
+ respond_to do |format|
46
+ if @<%= klass.table_name.singularize %>.save
47
+ format.html { redirect_to @<%= klass.table_name.singularize %>, notice: '<%= model_name %> was successfully created.' }
48
+ format.json { render json: @<%= klass.table_name.singularize %>, status: :created, location: @<%= klass.table_name.singularize %> }
49
+ else
50
+ format.html { render action: "new" }
51
+ format.json { render json: @<%= klass.table_name.singularize %>.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /<%= klass.table_name %>/1
57
+ # PUT /<%= klass.table_name %>/1.json
58
+ def update
59
+ @<%= klass.table_name.singularize %> = <%= model_name %>.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @<%= klass.table_name.singularize %>.update_attributes(params[:<%= klass.table_name.singularize %>])
63
+ format.html { redirect_to @<%= klass.table_name.singularize %>, notice: '<%= model_name %> was successfully updated.' }
64
+ format.json { head :ok }
65
+ else
66
+ format.html { render action: "edit" }
67
+ format.json { render json: @<%= klass.table_name.singularize %>.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /<%= klass.table_name %>/1
73
+ # DELETE /<%= klass.table_name %>/1.json
74
+ def destroy
75
+ @<%= klass.table_name.singularize %> = <%= model_name %>.find(params[:id])
76
+ @<%= klass.table_name.singularize %>.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to <%= klass.table_name %>_url }
80
+ format.json { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,27 @@
1
+ = f.inputs do
2
+ <%- model_attributes.each do |attr| -%>
3
+ <%- unless attr[0].match(/.*_id$|^id$/)-%> = f.input :<%= attr[0] -%>
4
+
5
+ <%- end -%>
6
+ <%- end -%>
7
+ <%- belong_tos.each do |bt| -%> = f.input :<%= bt.name %>
8
+ <%- end -%>
9
+ <%- have_ones.each do |ho| -%>= f.semantic_fields_for :<%= ho.name%> do |<%= ho.name%>|
10
+ <%- attributes_for(ho).each do |attr| -%>
11
+ <%- unless attr[0].match(/.*_id$|^id$/)-%> = <%= ho.name%>.input :<%= attr[0] -%>
12
+
13
+ <%- end -%>
14
+ <%- end -%>
15
+ <%- belong_tos_for(ho.active_record).each do |bt| -%>
16
+ <%- unless bt.name == klass.table_name -%> = <%= ho.name%>.input :<%= bt.name -%>
17
+
18
+ <%- end -%>
19
+ <%- end -%>
20
+ <%- end -%>
21
+ <%- have_manies.each do |hm| -%>%h3 <%= hm.name.to_s.pluralize.humanize%>
22
+ #<%= hm.name%>
23
+ = f.semantic_fields_for :<%= hm.name%> do |<%= hm.name.to_s.singularize%>|
24
+ = render '<%= hm.name.to_s.singularize%>_fields', :f => <%= hm.name.to_s.singularize %>
25
+ .links
26
+ = link_to_add_association 'add <%= hm.name.to_s.singularize %>', f, :<%= hm.name %>
27
+ <%- end -%>
@@ -0,0 +1,10 @@
1
+ .nested-fields
2
+ = f.inputs do
3
+ <%- attributes_for(@hm).each do |attr| -%>
4
+ <%- unless attr[0].match(/.*_id$|^id$/)-%> = f.input :<%= attr[0] %>
5
+ <%- end -%>
6
+ <%- end -%>
7
+ <%- belong_tos_for(@hm.klass).each do |bt| -%>
8
+ <%- unless bt.name.to_s == klass.table_name.to_s.singularize -%> = f.input :<%= bt.name -%>
9
+ <%- end -%>
10
+ <%- end -%>
@@ -0,0 +1,8 @@
1
+ %h2
2
+ Edit <%= model_name %>
3
+ = semantic_form_for(@<%= klass.table_name.singularize%>, :html => { :method => :put }) do |f|
4
+ = f.semantic_errors
5
+ = render 'form', :f => f
6
+ = f.buttons do
7
+ = f.commit_button :submit, "Update"
8
+ = link_to "Back", :back
@@ -0,0 +1,8 @@
1
+ %h2
2
+ Create <%= model_name %>
3
+ = semantic_form_for(@<%= klass.table_name.singularize%>, :html => { :method => :post }) do |f|
4
+ = f.semantic_errors
5
+ = render 'form', :f => f
6
+ = f.buttons do
7
+ = f.commit_button :submit, "Create"
8
+ = link_to "Back", :back
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,10 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require cocoon
10
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,83 @@
1
+ class MonkeysController < ApplicationController
2
+ # GET /monkeys
3
+ # GET /monkeys.json
4
+ def index
5
+ @monkeys = Monkey.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @monkeys }
10
+ end
11
+ end
12
+
13
+ # GET /monkeys/1
14
+ # GET /monkeys/1.json
15
+ def show
16
+ @monkey = Monkey.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render json: @monkey }
21
+ end
22
+ end
23
+
24
+ # GET /monkeys/new
25
+ # GET /monkeys/new.json
26
+ def new
27
+ @monkey = Monkey.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render json: @monkey }
32
+ end
33
+ end
34
+
35
+ # GET /monkeys/1/edit
36
+ def edit
37
+ @monkey = Monkey.find(params[:id])
38
+ end
39
+
40
+ # POST /monkeys
41
+ # POST /monkeys.json
42
+ def create
43
+ @monkey = Monkey.new(params[:monkey])
44
+
45
+ respond_to do |format|
46
+ if @monkey.save
47
+ format.html { redirect_to @monkey, notice: 'Monkey was successfully created.' }
48
+ format.json { render json: @monkey, status: :created, location: @monkey }
49
+ else
50
+ format.html { render action: "new" }
51
+ format.json { render json: @monkey.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /monkeys/1
57
+ # PUT /monkeys/1.json
58
+ def update
59
+ @monkey = Monkey.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @monkey.update_attributes(params[:monkey])
63
+ format.html { redirect_to @monkey, notice: 'Monkey was successfully updated.' }
64
+ format.json { head :ok }
65
+ else
66
+ format.html { render action: "edit" }
67
+ format.json { render json: @monkey.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /monkeys/1
73
+ # DELETE /monkeys/1.json
74
+ def destroy
75
+ @monkey = Monkey.find(params[:id])
76
+ @monkey.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to monkeys_url }
80
+ format.json { head :ok }
81
+ end
82
+ end
83
+ end