al-facebooker 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/CHANGELOG.txt +0 -0
  2. data/COPYING +19 -0
  3. data/History.txt +17 -0
  4. data/Manifest.txt +114 -0
  5. data/README +46 -0
  6. data/README.txt +97 -0
  7. data/Rakefile +76 -0
  8. data/TODO.txt +10 -0
  9. data/generators/facebook/facebook_generator.rb +14 -0
  10. data/generators/facebook/templates/config/facebooker.yml +46 -0
  11. data/generators/facebook/templates/public/javascripts/facebooker.js +106 -0
  12. data/generators/facebook_controller/USAGE +33 -0
  13. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  14. data/generators/facebook_controller/templates/controller.rb +7 -0
  15. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  16. data/generators/facebook_controller/templates/helper.rb +2 -0
  17. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  18. data/generators/facebook_controller/templates/view.html.erb +2 -0
  19. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  20. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  21. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  22. data/generators/facebook_scaffold/USAGE +27 -0
  23. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  24. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  25. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  26. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  27. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  28. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  29. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  30. data/generators/facebook_scaffold/templates/style.css +74 -0
  31. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  32. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  33. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  34. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  35. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  36. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  37. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  38. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  39. data/generators/publisher/publisher_generator.rb +14 -0
  40. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  41. data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
  42. data/init.rb +70 -0
  43. data/install.rb +12 -0
  44. data/lib/facebooker.rb +171 -0
  45. data/lib/facebooker/adapters/adapter_base.rb +87 -0
  46. data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
  47. data/lib/facebooker/adapters/facebook_adapter.rb +48 -0
  48. data/lib/facebooker/admin.rb +28 -0
  49. data/lib/facebooker/batch_request.rb +44 -0
  50. data/lib/facebooker/data.rb +57 -0
  51. data/lib/facebooker/feed.rb +78 -0
  52. data/lib/facebooker/logging.rb +51 -0
  53. data/lib/facebooker/model.rb +123 -0
  54. data/lib/facebooker/models/affiliation.rb +10 -0
  55. data/lib/facebooker/models/album.rb +11 -0
  56. data/lib/facebooker/models/applicationproperties.rb +39 -0
  57. data/lib/facebooker/models/cookie.rb +10 -0
  58. data/lib/facebooker/models/education_info.rb +11 -0
  59. data/lib/facebooker/models/event.rb +26 -0
  60. data/lib/facebooker/models/friend_list.rb +14 -0
  61. data/lib/facebooker/models/group.rb +35 -0
  62. data/lib/facebooker/models/info_item.rb +10 -0
  63. data/lib/facebooker/models/info_section.rb +10 -0
  64. data/lib/facebooker/models/location.rb +8 -0
  65. data/lib/facebooker/models/notifications.rb +17 -0
  66. data/lib/facebooker/models/page.rb +27 -0
  67. data/lib/facebooker/models/photo.rb +10 -0
  68. data/lib/facebooker/models/tag.rb +12 -0
  69. data/lib/facebooker/models/user.rb +396 -0
  70. data/lib/facebooker/models/work_info.rb +9 -0
  71. data/lib/facebooker/parser.rb +547 -0
  72. data/lib/facebooker/rails/controller.rb +280 -0
  73. data/lib/facebooker/rails/facebook_asset_path.rb +18 -0
  74. data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
  75. data/lib/facebooker/rails/facebook_pretty_errors.rb +14 -0
  76. data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
  77. data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
  78. data/lib/facebooker/rails/facebook_url_helper.rb +191 -0
  79. data/lib/facebooker/rails/facebook_url_rewriting.rb +39 -0
  80. data/lib/facebooker/rails/helpers.rb +681 -0
  81. data/lib/facebooker/rails/helpers/fb_connect.rb +34 -0
  82. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  83. data/lib/facebooker/rails/publisher.rb +510 -0
  84. data/lib/facebooker/rails/routing.rb +49 -0
  85. data/lib/facebooker/rails/test_helpers.rb +88 -0
  86. data/lib/facebooker/rails/utilities.rb +22 -0
  87. data/lib/facebooker/server_cache.rb +24 -0
  88. data/lib/facebooker/service.rb +92 -0
  89. data/lib/facebooker/session.rb +566 -0
  90. data/lib/facebooker/version.rb +9 -0
  91. data/lib/net/http_multipart_post.rb +123 -0
  92. data/lib/tasks/facebooker.rake +18 -0
  93. data/lib/tasks/tunnel.rake +46 -0
  94. data/rails/init.rb +1 -0
  95. data/setup.rb +1585 -0
  96. data/templates/layout.erb +24 -0
  97. data/test/adapters_test.rb +98 -0
  98. data/test/batch_request_test.rb +82 -0
  99. data/test/event_test.rb +15 -0
  100. data/test/facebook_admin_test.rb +76 -0
  101. data/test/facebook_cache_test.rb +44 -0
  102. data/test/facebook_data_test.rb +86 -0
  103. data/test/facebooker_test.rb +855 -0
  104. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  105. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  106. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  107. data/test/http_multipart_post_test.rb +54 -0
  108. data/test/logging_test.rb +43 -0
  109. data/test/model_test.rb +91 -0
  110. data/test/publisher_test.rb +458 -0
  111. data/test/rails_integration_test.rb +1224 -0
  112. data/test/session_test.rb +613 -0
  113. data/test/test_helper.rb +60 -0
  114. data/test/user_test.rb +270 -0
  115. metadata +185 -0
@@ -0,0 +1,106 @@
1
+
2
+ function $(element) {
3
+ if (typeof element == "string") {
4
+ element=document.getElementById(element);
5
+ }
6
+ if (element)
7
+ extend_instance(element,Element);
8
+ return element;
9
+ }
10
+
11
+ function extend_instance(instance,hash) {
12
+ for (var name in hash) {
13
+ instance[name] = hash[name];
14
+ }
15
+ }
16
+
17
+ var Element = {
18
+ "hide": function () {
19
+ this.setStyle("display","none")
20
+ },
21
+ "show": function () {
22
+ this.setStyle("display","block")
23
+ },
24
+ "visible": function () {
25
+ return (this.getStyle("display") != "none");
26
+ },
27
+ "toggle": function () {
28
+ if (this.visible) {
29
+ this.hide();
30
+ } else {
31
+ this.show();
32
+ }
33
+ }
34
+ };
35
+
36
+ function encodeURIComponent(str) {
37
+ if (typeof(str) == "string") {
38
+ return str.replace(/=/g,'%3D').replace(/&/g,'%26');
39
+ }
40
+ //checkboxes and radio buttons return objects instead of a string
41
+ else if(typeof(str) == "object"){
42
+ for (prop in str)
43
+ {
44
+ return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
45
+ }
46
+ }
47
+ };
48
+
49
+ var Form = {};
50
+ Form.serialize = function(form_element) {
51
+ elements=$(form_element).serialize();
52
+ param_string="";
53
+ for (var name in elements) {
54
+ if (param_string)
55
+ param_string += "&";
56
+ param_string += encodeURIComponent(name)+"="+encodeURIComponent(elements[name]);
57
+ }
58
+ return param_string;
59
+ };
60
+
61
+ Ajax.Updater = function (container,url,options) {
62
+ this.container = container;
63
+ this.url=url;
64
+ this.ajax = new Ajax();
65
+ this.ajax.requireLogin = 1;
66
+ if (options["onSuccess"]) {
67
+ this.ajax.responseType = Ajax.JSON;
68
+ this.ajax.ondone = options["onSuccess"];
69
+ } else {
70
+ this.ajax.responseType = Ajax.FBML;
71
+ this.ajax.ondone = function(data) {
72
+ $(container).setInnerFBML(data);
73
+ }
74
+ }
75
+ if (options["onFailure"]) {
76
+ this.ajax.onerror = options["onFailure"];
77
+ }
78
+
79
+ // Yes, this is an excercise in undoing what we just did
80
+ // FB doesn't provide encodeURI, but they will encode things passed as a hash
81
+ // so we turn it into a string, esaping & and =
82
+ // then we split it all back out here
83
+ // this could be killed if encodeURIComponent was available
84
+ parameters={};
85
+ if (options['parameters']) {
86
+ pairs=options['parameters'].split('&');
87
+ for (var i=0; i<pairs.length; i++) {
88
+ kv=pairs[i].split('=');
89
+ key=kv[0].replace(/%3D/g,'=').replace(/%26/g,'&');
90
+ val=kv[1].replace(/%3D/g,'=').replace(/%26/g,'&');
91
+ parameters[key]=val;
92
+ }
93
+ }
94
+ this.ajax.post(url,parameters);
95
+ if (options["onLoading"]) {
96
+ options["onLoading"].call()
97
+ }
98
+ };
99
+ Ajax.Request = function(url,options) {
100
+ Ajax.Updater('unused',url,options);
101
+ };
102
+
103
+ PeriodicalExecuter = function (callback, frequency) {
104
+ setTimeout(callback, frequency *1000);
105
+ setTimeout(function() { new PeriodicalExecuter(callback,frequency); }, frequency*1000);
106
+ };
@@ -0,0 +1,33 @@
1
+ Description:
2
+ Stubs out a new controller and its views. Pass the controller name, either
3
+ CamelCased or under_scored, and a list of views as arguments.
4
+
5
+ To create a controller within a module, specify the controller name as a
6
+ path like 'parent_module/controller_name'.
7
+
8
+ This generates a controller class in app/controllers, view templates in
9
+ app/views/controller_name, a helper class in app/helpers, and a functional
10
+ test suite in test/functional.
11
+
12
+ Also, it generates fbml view templates.
13
+
14
+ Example:
15
+ `./script/generate controller CreditCard open debit credit close`
16
+
17
+ Credit card controller with URLs like /credit_card/debit.
18
+ Controller: app/controllers/credit_card_controller.rb
19
+ Views: app/views/credit_card/debit.html.erb [...],
20
+ app/views/credit_card/debit.fbml.erb [...]
21
+ Helper: app/helpers/credit_card_helper.rb
22
+ Test: test/functional/credit_card_controller_test.rb
23
+
24
+ Modules Example:
25
+ `./script/generate controller 'admin/credit_card' suspend late_fee`
26
+
27
+ Credit card admin controller with URLs /admin/credit_card/suspend.
28
+ Controller: app/controllers/admin/credit_card_controller.rb
29
+ Views: app/views/admin/credit_card/debit.html.erb [...],
30
+ app/views/admin/credit_card/debit.fbml.erb [...]
31
+ Helper: app/helpers/admin/credit_card_helper.rb
32
+ Test: test/functional/admin/credit_card_controller_test.rb
33
+
@@ -0,0 +1,40 @@
1
+ class FacebookControllerGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ # Check for class naming collisions.
5
+ m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
6
+
7
+ # Controller, helper, views, and test directories.
8
+ m.directory File.join('app/controllers', class_path)
9
+ m.directory File.join('app/helpers', class_path)
10
+ m.directory File.join('app/views', class_path, file_name)
11
+ m.directory File.join('test/functional', class_path)
12
+
13
+ # Controller class, functional test, and helper class.
14
+ m.template 'controller.rb',
15
+ File.join('app/controllers',
16
+ class_path,
17
+ "#{file_name}_controller.rb")
18
+
19
+ m.template 'functional_test.rb',
20
+ File.join('test/functional',
21
+ class_path,
22
+ "#{file_name}_controller_test.rb")
23
+
24
+ m.template 'helper.rb',
25
+ File.join('app/helpers',
26
+ class_path,
27
+ "#{file_name}_helper.rb")
28
+
29
+ # View template for each action.
30
+ actions.each do |action|
31
+ html_path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
32
+ m.template 'view.html.erb', html_path,
33
+ :assigns => { :action => action, :path => html_path }
34
+ fbml_path = File.join('app/views', class_path, file_name, "#{action}.fbml.erb")
35
+ m.template 'view.fbml.erb', fbml_path,
36
+ :assigns => { :action => action, :path => fbml_path }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ class <%= class_name %>Controller < ApplicationController
2
+ <% for action in actions -%>
3
+ def <%= action %>
4
+ end
5
+
6
+ <% end -%>
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+ require File.dirname(__FILE__)+'/../../vendor/plugins/facebooker/lib/facebooker/rails/test_helpers.rb'
3
+
4
+ class <%= class_name %>ControllerTest < ActionController::TestCase
5
+ include Facebooker::Rails::TestHelpers
6
+
7
+ # Replace this with your real tests.
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ module <%= class_name %>Helper
2
+ end
@@ -0,0 +1,2 @@
1
+ <h1><%= class_name %>#<%= action %></h1>
2
+ <p>Find me in <%= path %></p>
@@ -0,0 +1,2 @@
1
+ <h1><%= class_name %>#<%= action %></h1>
2
+ <p>Find me in <%= path %></p>
@@ -0,0 +1,14 @@
1
+ class FacebookPublisherGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ m.directory "app/models"
5
+ m.template "publisher.rb", "app/models/#{file_name}_publisher.rb"
6
+ migration_file_name="create_facebook_templates"
7
+ # unless m.migration_exists?(migration_file_name)
8
+ # THis should work, but it doesn't. So we re-implement it instead
9
+ if Dir.glob(File.join(RAILS_ROOT,"db","migrate","[0-9]*_*.rb")).grep(/[0-9]+_create_facebook_templates.rb$/).blank?
10
+ m.migration_template "create_facebook_templates.rb", "db/migrate", :migration_file_name=>migration_file_name
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class CreateFacebookTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :facebook_templates, :force => true do |t|
4
+ t.string :template_name, :null => false
5
+ t.string :content_hash, :null => false
6
+ t.string :bundle_id, :null => true
7
+ end
8
+ add_index :facebook_templates, :template_name, :unique => true
9
+ end
10
+
11
+ def self.down
12
+ remove_index :facebook_templates, :template_name
13
+ drop_table :facebook_templates
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ class <%= class_name %>Publisher < Facebooker::Rails::Publisher
2
+
3
+ end
@@ -0,0 +1,27 @@
1
+ Description:
2
+ Scaffolds an entire resource, from model and migration to controller and
3
+ views, along with a full test suite. The resource is ready to use as a
4
+ starting point for your restful, resource-oriented application.
5
+
6
+ Pass the name of the model, either CamelCased or under_scored, as the first
7
+ argument, and an optional list of attribute pairs.
8
+
9
+ Attribute pairs are column_name:sql_type arguments specifying the
10
+ model's attributes. Timestamps are added by default, so you don't have to
11
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
12
+
13
+ You don't have to think up every attribute up front, but it helps to
14
+ sketch out a few so you can start working with the resource immediately.
15
+
16
+ For example, `scaffold post title:string body:text published:boolean`
17
+ gives you a model with those three attributes, a controller that handles
18
+ the create/show/update/destroy, forms to create and edit your posts, and
19
+ an index that lists them all, as well as a map.resources :posts
20
+ declaration in config/routes.rb.
21
+
22
+ Also, it creates Facebook view templates and functional tests.
23
+
24
+ Examples:
25
+ `./script/generate scaffold post` # no attributes, view will be anemic
26
+ `./script/generate scaffold post title:string body:text published:boolean`
27
+ `./script/generate scaffold purchase order_id:integer amount:decimal`
@@ -0,0 +1,118 @@
1
+ class Rails::Generator::Commands::Create
2
+ def register_fbml_mime_type_alias
3
+ path = destination_path('config/initializers/mime_types.rb')
4
+ content = "Mime::Type.register_alias 'text/html', :fbml"
5
+ unless File.read(path).match(Regexp.escape(content))
6
+ logger.register "text/html, :fbml"
7
+ File.open(path, 'a') { |file| file.write(content) }
8
+ end
9
+ end
10
+ end
11
+ class Rails::Generator::Commands::Destroy
12
+ def register_fbml_mime_type_alias
13
+ # do nothing
14
+ end
15
+ end
16
+
17
+ class FacebookScaffoldGenerator < Rails::Generator::NamedBase
18
+ default_options :skip_timestamps => false, :skip_migration => false
19
+
20
+ attr_reader :controller_name,
21
+ :controller_class_path,
22
+ :controller_file_path,
23
+ :controller_class_nesting,
24
+ :controller_class_nesting_depth,
25
+ :controller_class_name,
26
+ :controller_underscore_name,
27
+ :controller_singular_name,
28
+ :controller_plural_name
29
+ alias_method :controller_file_name, :controller_underscore_name
30
+ alias_method :controller_table_name, :controller_plural_name
31
+
32
+ def initialize(runtime_args, runtime_options = {})
33
+ super
34
+
35
+ @controller_name = @name.pluralize
36
+
37
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
38
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
39
+ @controller_singular_name=base_name.singularize
40
+ if @controller_class_nesting.empty?
41
+ @controller_class_name = @controller_class_name_without_nesting
42
+ else
43
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
44
+ end
45
+ end
46
+
47
+ def manifest
48
+ record do |m|
49
+ # Check for class naming collisions.
50
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
51
+ m.class_collisions(class_path, "#{class_name}")
52
+
53
+ # Controller, helper, views, test and stylesheets directories.
54
+ m.directory(File.join('app/models', class_path))
55
+ m.directory(File.join('app/controllers', controller_class_path))
56
+ m.directory(File.join('app/helpers', controller_class_path))
57
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
58
+ m.directory(File.join('app/views/layouts', controller_class_path))
59
+ m.directory(File.join('test/functional', controller_class_path))
60
+ m.directory(File.join('test/unit', class_path))
61
+ m.directory(File.join('public/stylesheets', class_path))
62
+
63
+ for action in scaffold_views
64
+ m.template(
65
+ "view_#{action}.html.erb",
66
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb")
67
+ )
68
+ m.template(
69
+ "view_#{action}.fbml.erb",
70
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.fbml.erb")
71
+ )
72
+ end
73
+
74
+ # Layout and stylesheet.
75
+ m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb"))
76
+ m.template('layout.fbml.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.fbml.erb"))
77
+ m.template('style.css', 'public/stylesheets/scaffold.css')
78
+ m.template('facebook_style.css', 'public/stylesheets/facebook_scaffold.css')
79
+
80
+ m.template(
81
+ 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
82
+ )
83
+
84
+ m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
85
+ m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
86
+
87
+ m.route_resources controller_file_name
88
+
89
+ m.dependency 'model', [name] + @args, :collision => :skip
90
+
91
+ m.register_fbml_mime_type_alias
92
+ end
93
+ end
94
+
95
+ protected
96
+ # Override with your own usage banner.
97
+ def banner
98
+ "Usage: #{$0} scaffold ModelName [field:type, field:type]"
99
+ end
100
+
101
+ def add_options!(opt)
102
+ opt.separator ''
103
+ opt.separator 'Options:'
104
+ opt.on("--skip-timestamps",
105
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
106
+ opt.on("--skip-migration",
107
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
108
+ end
109
+
110
+ def scaffold_views
111
+ %w[ index show new edit ]
112
+ end
113
+
114
+ def model_name
115
+ class_name.demodulize
116
+ end
117
+
118
+ end
@@ -0,0 +1,93 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ # GET /<%= table_name %>
3
+ # GET /<%= table_name %>.xml
4
+ def index
5
+ @<%= table_name %> = <%= class_name %>.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.fbml # index.fbml.erb
10
+ format.xml { render :xml => @<%= table_name %> }
11
+ end
12
+ end
13
+
14
+ # GET /<%= table_name %>/1
15
+ # GET /<%= table_name %>/1.xml
16
+ def show
17
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.fbml # show.fbml.erb
22
+ format.xml { render :xml => @<%= file_name %> }
23
+ end
24
+ end
25
+
26
+ # GET /<%= table_name %>/new
27
+ # GET /<%= table_name %>/new.xml
28
+ def new
29
+ @<%= file_name %> = <%= class_name %>.new
30
+
31
+ respond_to do |format|
32
+ format.html # new.html.erb
33
+ format.fbml # new.fbml.erb
34
+ format.xml { render :xml => @<%= file_name %> }
35
+ end
36
+ end
37
+
38
+ # GET /<%= table_name %>/1/edit
39
+ def edit
40
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
41
+ end
42
+
43
+ # POST /<%= table_name %>
44
+ # POST /<%= table_name %>.xml
45
+ def create
46
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
47
+
48
+ respond_to do |format|
49
+ if @<%= file_name %>.save
50
+ flash[:notice] = '<%= class_name %> was successfully created.'
51
+ format.html { redirect_to(@<%= file_name %>) }
52
+ format.fbml { redirect_to(@<%= file_name %>) }
53
+ format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
54
+ else
55
+ format.html { render :action => "new" }
56
+ format.fbml { render :action => "new" }
57
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
58
+ end
59
+ end
60
+ end
61
+
62
+ # PUT /<%= table_name %>/1
63
+ # PUT /<%= table_name %>/1.xml
64
+ def update
65
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
66
+
67
+ respond_to do |format|
68
+ if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
69
+ flash[:notice] = '<%= class_name %> was successfully updated.'
70
+ format.html { redirect_to(@<%= file_name %>) }
71
+ format.fbml { redirect_to(@<%= file_name %>) }
72
+ format.xml { head :ok }
73
+ else
74
+ format.html { render :action => "edit" }
75
+ format.fbml { render :action => "edit" }
76
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
77
+ end
78
+ end
79
+ end
80
+
81
+ # DELETE /<%= table_name %>/1
82
+ # DELETE /<%= table_name %>/1.xml
83
+ def destroy
84
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
85
+ @<%= file_name %>.destroy
86
+
87
+ respond_to do |format|
88
+ format.html { redirect_to(<%= table_name %>_url) }
89
+ format.fbml { redirect_to(<%= table_name %>_url) }
90
+ format.xml { head :ok }
91
+ end
92
+ end
93
+ end