restfulx 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +3 -1
  3. data/VERSION.yml +1 -1
  4. data/app_generators/rx_app/rx_app_generator.rb +2 -2
  5. data/app_generators/rx_app/templates/actionscript.properties +1 -1
  6. data/app_generators/rx_app/templates/actionscriptair.properties +1 -1
  7. data/app_generators/rx_app/templates/mainapp-config.xml +1 -0
  8. data/app_generators/rx_app/templates/mainapp.mxml +1 -1
  9. data/app_generators/rx_app/templates/restfulx.yml +26 -5
  10. data/lib/restfulx.rb +1 -1
  11. data/lib/restfulx/active_foo.rb +5 -2
  12. data/lib/restfulx/active_record_uuid_helper.rb +1 -1
  13. data/lib/restfulx/configuration.rb +15 -4
  14. data/lib/restfulx/rails/schema_to_yaml.rb +0 -11
  15. data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +4 -1
  16. data/lib/restfulx/rails/swf_helper.rb +7 -3
  17. data/lib/restfulx/tasks.rb +0 -1
  18. data/rails_generators/rx_config/rx_config_generator.rb +16 -7
  19. data/rails_generators/rx_config/templates/actionscript.properties +1 -1
  20. data/rails_generators/rx_config/templates/actionscriptair.properties +1 -1
  21. data/rails_generators/rx_config/templates/mainapp-config.xml +1 -0
  22. data/rails_generators/rx_config/templates/restfulx.erb +45 -8
  23. data/rails_generators/rx_config/templates/restfulx.yml +4 -4
  24. data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
  25. data/rails_generators/rx_main_app/rx_main_app_generator.rb +2 -2
  26. data/rails_generators/rx_main_app/templates/mainapp.mxml +1 -1
  27. data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +15 -6
  28. data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +2 -2
  29. data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
  30. data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
  31. data/rails_generators/rx_scaffold/templates/layouts/default.erb +7 -5
  32. data/rails_generators/rx_scaffold/templates/migration.rb.erb +4 -4
  33. data/rxgen_generators/rx_config/rx_config_generator.rb +2 -0
  34. data/rxgen_generators/rx_controller/templates/assist.py +1 -1
  35. data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +2 -2
  36. data/rxgen_generators/rx_main_app/templates/mainapp.mxml +1 -1
  37. data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +56 -9
  38. data/rxgen_generators/rx_scaffold/templates/{component.mxml.erb → layouts/default.erb} +56 -10
  39. data/rxgen_generators/rx_scaffold/templates/model.as.erb +33 -2
  40. data/test/rails/controllers/{application.rb → application_controller.rb} +0 -0
  41. data/test/rails/helpers/functional_test_helper.rb +1 -1
  42. data/test/rails/helpers/test_helper.rb +1 -8
  43. data/test/rails/helpers/unit_test_helper.rb +2 -3
  44. data/test/rails/test_active_foo.rb +1 -1
  45. data/test/rails/test_rails_integration_functional.rb +1 -1
  46. data/test/rails/test_to_fxml.rb +1 -1
  47. data/test/rails/test_to_json.rb +1 -1
  48. metadata +59 -73
data/README.rdoc CHANGED
@@ -39,7 +39,7 @@ For details on how to get started with the RestfulX framework refer to:
39
39
 
40
40
  Report bugs or track framework development progress:
41
41
 
42
- http://restfulx.lighthouseapp.com/dashboard
42
+ http://github.com/dima/restfulx_framework/issues
43
43
 
44
44
  Get involved with the community:
45
45
 
data/Rakefile CHANGED
@@ -10,11 +10,13 @@ begin
10
10
  gem.rubyforge_project = "restfulx"
11
11
  gem.authors = ["Dima Berastau"]
12
12
  gem.files = FileList["[A-Z]*", "{bin,app_generators,rails_generators,rxgen_generators,lib,test,spec,tasks}/**/*"]
13
+ gem.files.exclude 'test/**/*.log', 'test/**/*.sqlite3'
14
+ gem.test_files.exclude 'test/**/*.log', 'test/**/*.sqlite3'
13
15
  gem.add_dependency('rubigen', '>= 1.5.0')
14
16
  gem.add_dependency('activesupport', '>=2.0.0')
15
17
  end
16
18
  rescue LoadError
17
- puts "Jeweler not available. Install it with: sudo gem install dima-jeweler -s http://gems.github.com"
19
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
18
20
  end
19
21
 
20
22
  require 'rake/rdoctask'
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
3
2
  :major: 1
4
3
  :minor: 2
4
+ :patch: 3
@@ -79,11 +79,11 @@ class RxAppGenerator < RubiGen::Base
79
79
  m.template 'index.html.erb', 'public/index.html'
80
80
  end
81
81
 
82
- %w(components controllers commands models events).each do |dir|
82
+ %w(views controllers commands models events helpers).each do |dir|
83
83
  m.directory "#{flex_root}/#{base_folder}/#{dir}"
84
84
  end
85
85
 
86
- m.directory "#{flex_root}/#{base_folder}/components/generated"
86
+ m.directory "#{flex_root}/#{base_folder}/views/generated"
87
87
 
88
88
  m.template 'project-textmate.erb', "#{project_name}.tmproj"
89
89
  m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <actionScriptProperties mainApplicationPath="<%= flex_project_name %>.mxml" version="3">
3
- <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
3
+ <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored,Nested" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <actionScriptProperties mainApplicationPath="<%= flex_project_name %>.mxml" version="3">
3
- <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
3
+ <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored,Nested" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -11,6 +11,7 @@
11
11
  <name>DateTime</name>
12
12
  <name>Lazy</name>
13
13
  <name>Ignored</name>
14
+ <name>Nested</name>
14
15
  </keep-as3-metadata>
15
16
  <optimize>true</optimize>
16
17
  <keep-generated-actionscript>false</keep-generated-actionscript>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <mx:<%= application_tag %> xmlns:mx="http://www.adobe.com/2006/mxml"
3
- xmlns:generated="<%= base_package %>.components.generated.*"
3
+ xmlns:generated="<%= base_package %>.views.generated.*"
4
4
  paddingBottom="8" paddingLeft="8" paddingRight="8" paddingTop="8"
5
5
  layout="horizontal" styleName="plain" initialize="init()">
6
6
  <mx:Script>
@@ -2,24 +2,45 @@
2
2
 
3
3
  # This option controls what the main Flex application file will be called.
4
4
  # By default it will be equal to the name of your rails project camelized
5
- project-name: <%= project_name %>
5
+ project_name: <%= project_name %>
6
6
 
7
7
  # This options determines what the root folder for generated Flex code is.
8
8
  # By default 'app/flex'
9
- flex-root: <%= flex_root %>
9
+ flex_root: <%= flex_root %>
10
10
 
11
11
  # By default flex models, commands, controllers and components are genearated into
12
12
  # <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
13
13
  # (to say append a "com" package before your rails project name) uncomment the line below
14
14
  # base-package must follow the usual flex package notation (a string separated by ".")
15
- base-package: <%= base_package %>
15
+ base_package: <%= base_package %>
16
16
 
17
17
  # Main RestfulX controller is typically named AppicationController. This controller is created in
18
18
  # <base-package>.controllers folder. You can customize the name by uncommenting the following line
19
19
  # and changing the controller name.
20
- controller-name: <%= command_controller_name %>
20
+ controller_name: <%= command_controller_name %>
21
21
 
22
22
  # If you are using Rails on the back-end and Adobe AIR as the client you can generate Rails/Flex/AIR
23
23
  # code to take advantage of synchronization (online/offline) support in RestfulX by changing the following
24
24
  # option to true. By default distribution is disabled.
25
- distributed: <%= distributed %>
25
+ distributed: <%= distributed %>
26
+
27
+ # Choose the layout to use for generated Flex view components
28
+ layouts:
29
+ default: 'default'
30
+
31
+ # The following special model.yml fields are supported.
32
+ #
33
+ # For example:
34
+ # attachment_field: [avatar]
35
+ # * arg takes Paperclip field name, or takes [uploaded_data] for Attachment_Fu
36
+ # belongs_to: [account, profile]
37
+ # has_many: [announcements, files, folders, users]
38
+ # has_many_through: [permissions, roles]
39
+ # * has_many :roles, :through => :permissions
40
+ # has_one: [suitcase]
41
+ # polymorphic: [commentable]
42
+ # tree_model: [parent]
43
+ # layout: [default]
44
+ # * default template is the only current theme, with more coming soon
45
+ # ignored_fields: [children_count, ancestors_count, descendants_count, position]
46
+ # * specify fields you don't want generated for your template
data/lib/restfulx.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  module RestfulX
6
6
 
7
7
  # :stopdoc:
8
- FRAMEWORK_VERSION = '1.2.2'
8
+ FRAMEWORK_VERSION = '1.2.3'
9
9
  LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
10
10
  # :startdoc:
11
11
 
@@ -88,6 +88,9 @@ module ActiveSupport
88
88
  options[:indent] ||= 2
89
89
  options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
90
90
  options.merge!(:dasherize => false)
91
+
92
+ options[:attributes] ||= {}
93
+ options[:attributes].merge!(:type => "array")
91
94
 
92
95
  root = options.delete(:root).to_s
93
96
  children = options.delete(:children)
@@ -102,9 +105,9 @@ module ActiveSupport
102
105
 
103
106
  xml = options[:builder]
104
107
  if empty?
105
- xml.tag!(root, options[:skip_types] ? {} : {:type => "array"})
108
+ xml.tag!(root, options[:attributes])
106
109
  else
107
- xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
110
+ xml.tag!(root, options[:attributes]) {
108
111
  yield xml if block_given?
109
112
  each { |e| e.to_fxml(opts.merge!({ :skip_instruct => true })) }
110
113
  }
@@ -11,7 +11,7 @@ module RestfulX
11
11
  end
12
12
 
13
13
  def generate_uuid
14
- self.id = UUID.random_create.to_s.gsub("-", "") unless self.id
14
+ self.id = UUIDTools::UUID.random_create.to_s.gsub("-", "") unless self.id
15
15
  end
16
16
  end
17
17
  end
@@ -1,6 +1,15 @@
1
1
  # Interestingly enough there's no way to *just* upper-case or down-case first letter of a given
2
2
  # string. Ruby's own +capitalize+ actually downcases all the rest of the characters in the string
3
3
  # We patch the class to add our own implementation.
4
+ require "yaml"
5
+ require "erb"
6
+ require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/config"
7
+ require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/core"
8
+
9
+ Dir[File.dirname(__FILE__) + "/rails/schema_to_yaml/extensions/*.rb"].each do |f|
10
+ require f
11
+ end
12
+
4
13
  class String
5
14
  # Upper-case first character of a string leave the rest of the string intact
6
15
  def ucfirst
@@ -20,6 +29,8 @@ module RestfulX
20
29
  module Configuration
21
30
  # We try to figure out the application root using a number of possible options
22
31
  APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
32
+
33
+ RxSettings = SchemaToYaml::Settings::Core
23
34
 
24
35
  # Extract project, package, controller name, etc from the environment. This will respect
25
36
  # config/restfulx.yml if it exists, you can override all of the defaults there.
@@ -35,12 +46,12 @@ module RestfulX
35
46
  # give a chance to override the settings via restfulx.yml
36
47
  begin
37
48
  config = YAML.load(File.open("#{APP_ROOT}/config/restfulx.yml"))
38
- base_package = config['base-package'] || flex_project_name.downcase
49
+ base_package = config['base_package'] || flex_project_name.downcase
39
50
  base_folder = base_package.gsub('.', '/')
40
- project_name = config['project-name'].downcase.gsub(/\W/, '') || project_name
51
+ project_name = config['project_name'].downcase.gsub(/\W/, '') || project_name
41
52
  flex_project_name = project_name.camelize
42
- controller_name = config['controller-name'] || "ApplicationController"
43
- flex_root = config['flex-root'] || "app/flex"
53
+ controller_name = config['controller_name'] || "ApplicationController"
54
+ flex_root = config['flex_root'] || "app/flex"
44
55
  distributed = config['distributed'] || false
45
56
  rescue
46
57
  base_folder = base_package = flex_project_name.downcase
@@ -1,18 +1,7 @@
1
1
  # Used for analyzing your schema and exporting a model.yml file for Rx
2
- require "yaml"
3
- require "erb"
4
- require File.dirname(__FILE__) + "/schema_to_yaml/settings/config"
5
- require File.dirname(__FILE__) + "/schema_to_yaml/settings/core"
6
-
7
- Dir[File.dirname(__FILE__) + "/schema_to_yaml/extensions/*.rb"].each do |f|
8
- require f
9
- end
10
-
11
2
  # Provides facilities to convert an existing Rails application schema.rb file to
12
3
  # RestfulX model.yml file
13
4
  module SchemaToYaml
14
- RxSettings = SchemaToYaml::Settings::Core
15
-
16
5
  # SchemaToYaml.schema_to_yaml
17
6
  # - set of commands that introspects your database and formats your model.yml for export
18
7
  def self.schema_to_yaml
@@ -2,6 +2,9 @@
2
2
  # Used to read in settings from restfulx.yml for use in code generation
3
3
  module SchemaToYaml
4
4
  module Settings
5
+ # We try to figure out the application root using a number of possible options
6
+ APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
7
+
5
8
  class Core
6
9
  class << self
7
10
  def name
@@ -29,7 +32,7 @@ module SchemaToYaml
29
32
  when Hash
30
33
  self._settings = name_or_hash
31
34
  when String, Symbol
32
- root_path = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/" : ""
35
+ root_path = defined?(APP_ROOT) ? "#{APP_ROOT}/config/" : ""
33
36
  file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash
34
37
  self._settings = YAML.load(ERB.new(File.read(file_path)).result)
35
38
  self._settings = _settings[RAILS_ENV] if defined?(RAILS_ENV)
@@ -10,8 +10,8 @@ module SWFHelper
10
10
  :version => '9.0.0',
11
11
  :express_install_swf => '/expressInstall.swf',
12
12
  :flash_vars => nil,
13
- :params => nil,
14
- :attributes => nil,
13
+ :params => { },
14
+ :attributes => { },
15
15
  :create_div => false,
16
16
  :include_authenticity_token => true,
17
17
  :include_session_token => true
@@ -34,7 +34,11 @@ module SWFHelper
34
34
  params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
35
35
  end
36
36
  if params[:include_session_token]
37
- params[:flash_vars].reverse_merge!(:session_token => session.session_id)
37
+ if RAILS_GEM_VERSION =~ /^2.3/
38
+ params[:flash_vars].reverse_merge!(:session_token => request.session_options[:id])
39
+ else
40
+ params[:flash_vars].reverse_merge!(:session_token => session.session_id)
41
+ end
38
42
  end
39
43
  end
40
44
 
@@ -1,6 +1,5 @@
1
1
  # Rake tasks for building RestfulX-based Flex and AIR applications
2
2
  require 'rake'
3
- require 'ftools'
4
3
  require 'rexml/document'
5
4
  require 'activesupport'
6
5
  require File.join(File.dirname(__FILE__), 'configuration')
@@ -49,8 +49,8 @@ class RxConfigGenerator < Rails::Generator::Base
49
49
  end
50
50
 
51
51
  @component_names = []
52
- if File.exists?("#{flex_root}/#{base_folder}/components/generated")
53
- @component_names = list_mxml_files("#{flex_root}/#{base_folder}/components/generated")
52
+ if File.exists?("#{flex_root}/#{base_folder}/views/generated")
53
+ @component_names = list_mxml_files("#{flex_root}/#{base_folder}/views/generated")
54
54
  end
55
55
  end
56
56
 
@@ -61,6 +61,8 @@ class RxConfigGenerator < Rails::Generator::Base
61
61
  m.template 'restfulx.yml', 'config/restfulx.yml'
62
62
  m.template 'restfulx.erb', 'config/initializers/restfulx.rb'
63
63
 
64
+ m.template 'session_store_flash.erb', 'config/initializers/session_store_flash.rb' if RAILS_GEM_VERSION =~ /2.3/
65
+
64
66
  m.directory "#{flex_root}"
65
67
 
66
68
  if @use_air
@@ -85,19 +87,26 @@ class RxConfigGenerator < Rails::Generator::Base
85
87
  m.file "html-template/history/#{file}", "html-template/history/#{file}"
86
88
  end
87
89
 
88
- %w(components controllers commands models events).each do |dir|
90
+ %w(views controllers commands models events helpers).each do |dir|
89
91
  m.directory "#{flex_root}/#{base_folder}/#{dir}"
90
92
  end
91
93
 
92
- m.directory "#{flex_root}/#{base_folder}/components/generated"
94
+ m.directory "#{flex_root}/#{base_folder}/views/generated"
93
95
 
94
96
  framework_release = RestfulX::FRAMEWORK_VERSION
95
97
  framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
96
98
  framework_destination_file = "lib/restfulx-#{framework_release}.swc"
97
99
 
98
100
  if !options[:skip_framework] && !File.exist?(framework_destination_file)
99
- puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
100
- open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
101
+ puts "Fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
102
+ begin
103
+ framework_swc = open(framework_distribution_url).read
104
+ rescue
105
+ puts "ERROR: Unable to download and install #{framework_distribution_url}."
106
+ puts "Please check your internet connectivity and try again."
107
+ exit
108
+ end
109
+ open(framework_destination_file, "wb").write(framework_swc) unless framework_swc.blank?
101
110
  puts "done. saved to #{framework_destination_file}"
102
111
  end
103
112
 
@@ -110,7 +119,7 @@ class RxConfigGenerator < Rails::Generator::Base
110
119
 
111
120
  m.template 'index.erb', 'app/views/flex/index.html.erb'
112
121
 
113
- m.file 'routes.erb', 'config/routes.rb', :collision => :force
122
+ m.file 'routes.erb', 'config/routes.rb', :collision => :ask
114
123
 
115
124
  FileUtils.rm 'public/index.html' if File.exist?('public/index.html')
116
125
 
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <actionScriptProperties mainApplicationPath="<%= flex_project_name %>.mxml" version="3">
3
- <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
3
+ <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored,Nested" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <actionScriptProperties mainApplicationPath="<%= flex_project_name %>.mxml" version="3">
3
- <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
3
+ <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored,Nested" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -11,6 +11,7 @@
11
11
  <name>DateTime</name>
12
12
  <name>Lazy</name>
13
13
  <name>Ignored</name>
14
+ <name>Nested</name>
14
15
  </keep-as3-metadata>
15
16
  <optimize>true</optimize>
16
17
  <keep-generated-actionscript>false</keep-generated-actionscript>
@@ -1,11 +1,47 @@
1
- # When you do file uploads from Flash with File.upload() that, unfortunately generates a new session id,
2
- # which will fail to authenticate if you are using restful-authentication plugin or equivalent.
3
- #
4
- # The following code is a work-around for the Flash bug that prevents file uploader
5
- # from sending correct session_id. Here, we hack the Session#initialize method and force the session_id
6
- # to load from the query string via the request URI.
7
- #
8
- # Based on the code from http://seventytwo.co.uk/posts/making-swfupload-and-rails-work-together
1
+ # the following patches allow us to overwrite session key on file uploads from Flash,
2
+ # which ends up creating a new session for every File.upload() invocation.
3
+
4
+ <% if RAILS_GEM_VERSION =~ /^2.3/ -%>
5
+ require 'rack/utils'
6
+
7
+ class FlashSessionCookieMiddleware
8
+ def initialize(app, session_key = '_session_id')
9
+ @app = app
10
+ @session_key = session_key
11
+ @session_token = "_session_id"
12
+ end
13
+
14
+ def call(env)
15
+ if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
16
+ params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
17
+ env['HTTP_COOKIE'] = [ @session_key, params[@session_token] ].join('=').freeze unless params[@session_token].nil?
18
+ end
19
+ @app.call(env)
20
+ end
21
+ end
22
+
23
+ class FlexNestedAttributeMiddleware
24
+ def initialize(app)
25
+ @app = app
26
+ end
27
+
28
+ def call(env)
29
+ req = Rack::Request.new(env)
30
+ if req && req.path_info =~ /\.fxml$/
31
+ if req.put? || req.post? || req.delete?
32
+ req.params.each do |key,value|
33
+ value.select { |k,v| k =~ /\_attributes$/ }.each do |match|
34
+ env['rack.request.form_hash'][key][match[0]] = ActiveSupport::JSON.decode(match[1])
35
+ end
36
+ end
37
+ end
38
+ end
39
+ @app.call(env)
40
+ end
41
+ end
42
+
43
+ ActionController::Dispatcher.middleware.insert_after 'ActionController::ParamsParser', FlexNestedAttributeMiddleware
44
+ <% else -%>
9
45
  class CGI::Session
10
46
  alias original_initialize initialize
11
47
 
@@ -26,6 +62,7 @@ class CGI::Session
26
62
  return option
27
63
  end
28
64
  end
65
+ <% end -%>
29
66
 
30
67
  # If you have configured your Rails/Flex/AIR application to share authenticity_token
31
68
  # comment this out to enable forgery protection. By default, this is disabled to allow
@@ -2,22 +2,22 @@
2
2
 
3
3
  # This option controls what the main Flex application file will be called.
4
4
  # By default it will be equal to the name of your rails project camelized
5
- project-name: <%= project_name %>
5
+ project_name: <%= project_name %>
6
6
 
7
7
  # This options determines what the root folder for generated Flex code is.
8
8
  # By default 'app/flex'
9
- flex-root: <%= flex_root %>
9
+ flex_root: <%= flex_root %>
10
10
 
11
11
  # By default flex models, commands, controllers and components are genearated into
12
12
  # <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
13
13
  # (to say append a "com" package before your rails project name) uncomment the line below
14
14
  # base-package must follow the usual flex package notation (a string separated by ".")
15
- base-package: <%= base_package %>
15
+ base_package: <%= base_package %>
16
16
 
17
17
  # Main RestfulX controller is typically named AppicationController. This controller is created in
18
18
  # <base-package>.controllers folder. You can customize the name by uncommenting the following line
19
19
  # and changing the controller name.
20
- controller-name: <%= command_controller_name %>
20
+ controller_name: <%= command_controller_name %>
21
21
 
22
22
  # If you are using Rails on the back-end and Adobe AIR as the client you can generate Rails/Flex/AIR
23
23
  # code to take advantage of synchronization (online/offline) support in RestfulX by changing the following