nileshtrivedi-lp_resource_builder 0.5.1 → 0.5.3

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.
data/README.rdoc CHANGED
@@ -6,23 +6,15 @@ resource_controller makes RESTful controllers easier, more maintainable, and sup
6
6
 
7
7
  Add it as a gem dependency
8
8
 
9
- config.gem 'resource_controller'
10
-
11
- ...or for the development version
12
-
13
- config.gem 'giraffesoft-resource_controller', :lib => 'resource_controller', :source => 'http://gems.github.com'
9
+ config.gem 'nileshtrivedi-lp_resource_builder', :lib => 'resource_controller', :source => 'http://gems.github.com'
14
10
 
15
11
  Or install it as a gem manually
16
12
 
17
- sudo gem install resource_controller
18
-
19
- ...or for the development version
20
-
21
- sudo gem install giraffesoft-resource_controller
13
+ sudo gem install nileshtrivedi-lp_resource_builder
22
14
 
23
15
  Or grab the source
24
16
 
25
- git clone git://github.com/giraffesoft/resource_controller.git
17
+ git clone git://github.com/nileshtrivedi/resource_controller.git
26
18
 
27
19
  = Usage
28
20
 
@@ -318,7 +310,7 @@ Or with namespaced, nested controllers...
318
310
  You get the idea. Everything is automagical! All parameters are inferred.
319
311
 
320
312
  == Credits
321
-
313
+ resource_builder is a fork of resource_controller, maintained by {Nilesh Trivedi}[http://nileshtrivedi.in]
322
314
  resource_controller was created, and is maintained by {James Golick}[http://jamesgolick.com].
323
315
 
324
316
  == License
data/Rakefile CHANGED
@@ -1,26 +1,13 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
- require File.dirname(__FILE__)+'/lib/resource_controller/version'
5
- Dir['tasks/**.rake'].each { |tasks| load tasks }
6
-
7
- desc 'Default: run unit tests.'
8
- task :default => :test
9
-
10
- desc 'Test the ResourceController plugin.'
11
- Rake::TestTask.new(:test) do |t|
12
- t.libs << 'lib'
13
- t.pattern = 'test/test/**/*_test.rb'
14
- t.verbose = true
15
- end
1
+ Dir.chdir('test')
2
+ load 'Rakefile'
16
3
 
17
4
  desc 'Generate documentation for the ResourceController plugin.'
18
5
  Rake::RDocTask.new(:rdoc) do |rdoc|
19
- rdoc.rdoc_dir = 'rdoc'
6
+ rdoc.rdoc_dir = '../rdoc'
20
7
  rdoc.title = 'ResourceController'
21
8
  rdoc.options << '--line-numbers' << '--inline-source'
22
- rdoc.rdoc_files.include('README.rdoc')
23
- rdoc.rdoc_files.include('lib/**/*.rb')
9
+ rdoc.rdoc_files.include('../README.rdoc')
10
+ rdoc.rdoc_files.include('../lib/**/*.rb')
24
11
  end
25
12
 
26
13
  task :upload_docs => :rdoc do
@@ -28,8 +15,8 @@ task :upload_docs => :rdoc do
28
15
  `ssh jamesgolick.com 'rm -Rf /home/apps/jamesgolick.com/public/resource_controller/rdoc'`
29
16
 
30
17
  puts "Uploading current rdoc"
31
- `scp -r rdoc jamesgolick.com:/home/apps/jamesgolick.com/public/resource_controller`
18
+ `scp -r ../rdoc jamesgolick.com:/home/apps/jamesgolick.com/public/resource_controller`
32
19
 
33
20
  puts "Deleting rdoc"
34
- `rm -Rf rdoc`
21
+ `rm -Rf ../rdoc`
35
22
  end
@@ -2,5 +2,6 @@
2
2
  <p>
3
3
  <label for="<%= singular_name %>_<%= attribute.name %>"><%= attribute.column.human_name %>:</label>
4
4
  <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
5
+ <%%= error_message_on "<%= singular_name %>", "<%= attribute.name %>" %>
5
6
  </p>
6
- <% end -%>
7
+ <% end -%>
@@ -1,8 +1,6 @@
1
1
  <%% if @<%= singular_name %>.editable_by?(current_user) %>
2
2
  <h1>Editing <%= singular_name.titleize %></h1>
3
-
4
3
  <%%= error_messages_for :<%= singular_name %> %>
5
-
6
4
  <%% form_for(:<%= singular_name %>, :url => object_url, :html => { :method => :put }) do |f| %>
7
5
  <%%= render(:partial => "form", :locals => {:f => f}) %>
8
6
  <p>
@@ -1,7 +1,5 @@
1
1
  <h1>New <%= singular_name.titleize %></h1>
2
2
 
3
- <%%= error_messages_for :<%= singular_name %> %>
4
-
5
3
  <%% form_for(:<%= singular_name %>, :url => collection_url) do |f| %>
6
4
  <%%= render(:partial => "form", :locals => {:f => f}) %>
7
5
  <p>
@@ -1,69 +1,73 @@
1
- module ResourceController::Helpers::CurrentObjects
2
- protected
3
- # Used internally to return the model for your resource.
4
- #
5
- def model
6
- model_name.to_s.camelize.constantize
7
- end
1
+ module ResourceController
2
+ module Helpers
3
+ module CurrentObjects
4
+ protected
5
+ # Used internally to return the model for your resource.
6
+ #
7
+ def model
8
+ model_name.to_s.camelize.constantize
9
+ end
8
10
 
9
11
 
10
- # Used to fetch the collection for the index method
11
- #
12
- # In order to customize the way the collection is fetched, to add something like pagination, for example, override this method.
13
- #
14
- def collection
15
- end_of_association_chain.find(:all)
16
- end
12
+ # Used to fetch the collection for the index method
13
+ #
14
+ # In order to customize the way the collection is fetched, to add something like pagination, for example, override this method.
15
+ #
16
+ def collection
17
+ end_of_association_chain.find(:all)
18
+ end
17
19
 
18
- # Returns the current param.
19
- #
20
- # Defaults to params[:id].
21
- #
22
- # Override this method if you'd like to use an alternate param name.
23
- #
24
- def param
25
- params[:id]
26
- end
20
+ # Returns the current param.
21
+ #
22
+ # Defaults to params[:id].
23
+ #
24
+ # Override this method if you'd like to use an alternate param name.
25
+ #
26
+ def param
27
+ params[:id]
28
+ end
27
29
 
28
- # Used to fetch the current member object in all of the singular methods that operate on an existing member.
29
- #
30
- # Override this method if you'd like to fetch your objects in some alternate way, like using a permalink.
31
- #
32
- # class PostsController < ResourceController::Base
33
- # private
34
- # def object
35
- # @object ||= end_of_association_chain.find_by_permalink(param)
36
- # end
37
- # end
38
- #
39
- def object
40
- @object ||= end_of_association_chain.find(param) unless param.nil?
41
- @object
42
- end
30
+ # Used to fetch the current member object in all of the singular methods that operate on an existing member.
31
+ #
32
+ # Override this method if you'd like to fetch your objects in some alternate way, like using a permalink.
33
+ #
34
+ # class PostsController < ResourceController::Base
35
+ # private
36
+ # def object
37
+ # @object ||= end_of_association_chain.find_by_permalink(param)
38
+ # end
39
+ # end
40
+ #
41
+ def object
42
+ @object ||= end_of_association_chain.find(param) unless param.nil?
43
+ @object
44
+ end
43
45
 
44
- # Used internally to load the member object in to an instance variable @#{model_name} (i.e. @post)
45
- #
46
- def load_object
47
- instance_variable_set "@#{parent_type}", parent_object if parent?
48
- instance_variable_set "@#{object_name}", object
49
- end
46
+ # Used internally to load the member object in to an instance variable @#{model_name} (i.e. @post)
47
+ #
48
+ def load_object
49
+ instance_variable_set "@#{parent_type}", parent_object if parent?
50
+ instance_variable_set "@#{object_name}", object
51
+ end
50
52
 
51
- # Used internally to load the collection in to an instance variable @#{model_name.pluralize} (i.e. @posts)
52
- #
53
- def load_collection
54
- instance_variable_set "@#{parent_type}", parent_object if parent?
55
- instance_variable_set "@#{object_name.to_s.pluralize}", collection
56
- end
53
+ # Used internally to load the collection in to an instance variable @#{model_name.pluralize} (i.e. @posts)
54
+ #
55
+ def load_collection
56
+ instance_variable_set "@#{parent_type}", parent_object if parent?
57
+ instance_variable_set "@#{object_name.to_s.pluralize}", collection
58
+ end
57
59
 
58
- # Returns the form params. Defaults to params[model_name] (i.e. params["post"])
59
- #
60
- def object_params
61
- params["#{object_name}"]
62
- end
60
+ # Returns the form params. Defaults to params[model_name] (i.e. params["post"])
61
+ #
62
+ def object_params
63
+ params["#{object_name}"]
64
+ end
63
65
 
64
- # Builds the object, but doesn't save it, during the new, and create action.
65
- #
66
- def build_object
67
- @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
66
+ # Builds the object, but doesn't save it, during the new, and create action.
67
+ #
68
+ def build_object
69
+ @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
70
+ end
68
71
  end
72
+ end
69
73
  end
@@ -2,75 +2,79 @@
2
2
  #
3
3
  # All of these methods are used internally to execute the options, set by the user in ActionOptions and FailableActionOptions
4
4
  #
5
- module ResourceController::Helpers::Internal
6
- protected
7
- # Used to actually pass the responses along to the controller's respond_to method.
8
- #
9
- def response_for(action)
10
- respond_to do |wants|
11
- options_for(action).response.each do |method, block|
12
- if block.nil?
13
- wants.send(method)
14
- else
15
- wants.send(method) { instance_eval(&block) }
5
+ module ResourceController
6
+ module Helpers
7
+ module Internal
8
+ protected
9
+ # Used to actually pass the responses along to the controller's respond_to method.
10
+ #
11
+ def response_for(action)
12
+ respond_to do |wants|
13
+ options_for(action).response.each do |method, block|
14
+ if block.nil?
15
+ wants.send(method)
16
+ else
17
+ wants.send(method) { instance_eval(&block) }
18
+ end
19
+ end
16
20
  end
17
21
  end
18
- end
19
- end
22
+
23
+ # Calls the after callbacks for the action, if one is present.
24
+ #
25
+ def after(action)
26
+ invoke_callbacks *options_for(action).after
27
+ end
28
+
29
+ # Calls the before block for the action, if one is present.
30
+ #
31
+ def before(action)
32
+ invoke_callbacks *self.class.send(action).before
33
+ end
20
34
 
21
- # Calls the after callbacks for the action, if one is present.
22
- #
23
- def after(action)
24
- invoke_callbacks *options_for(action).after
25
- end
35
+ # Sets the flash and flash_now for the action, if it is present.
36
+ #
37
+ def set_flash(action)
38
+ set_normal_flash(action)
39
+ set_flash_now(action)
40
+ end
26
41
 
27
- # Calls the before block for the action, if one is present.
28
- #
29
- def before(action)
30
- invoke_callbacks *self.class.send(action).before
31
- end
32
-
33
- # Sets the flash and flash_now for the action, if it is present.
34
- #
35
- def set_flash(action)
36
- set_normal_flash(action)
37
- set_flash_now(action)
38
- end
39
-
40
- # Sets the regular flash (i.e. flash[:notice] = '...')
41
- #
42
- def set_normal_flash(action)
43
- if f = options_for(action).flash
44
- flash[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash
45
- end
46
- end
47
-
48
- # Sets the flash.now (i.e. flash.now[:notice] = '...')
49
- #
50
- def set_flash_now(action)
51
- if f = options_for(action).flash_now
52
- flash.now[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash_now
53
- end
54
- end
55
-
56
- # Returns the options for an action, which is a symbol.
57
- #
58
- # Manages splitting things like :create_fails.
59
- #
60
- def options_for(action)
61
- action = action == :new_action ? [action] : "#{action}".split('_').map(&:to_sym)
62
- options = self.class.send(action.first)
63
- options = options.send(action.last == :fails ? :fails : :success) if ResourceController::FAILABLE_ACTIONS.include? action.first
42
+ # Sets the regular flash (i.e. flash[:notice] = '...')
43
+ #
44
+ def set_normal_flash(action)
45
+ if f = options_for(action).flash
46
+ flash[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash
47
+ end
48
+ end
49
+
50
+ # Sets the flash.now (i.e. flash.now[:notice] = '...')
51
+ #
52
+ def set_flash_now(action)
53
+ if f = options_for(action).flash_now
54
+ flash.now[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash_now
55
+ end
56
+ end
57
+
58
+ # Returns the options for an action, which is a symbol.
59
+ #
60
+ # Manages splitting things like :create_fails.
61
+ #
62
+ def options_for(action)
63
+ action = action == :new_action ? [action] : "#{action}".split('_').map(&:to_sym)
64
+ options = self.class.send(action.first)
65
+ options = options.send(action.last == :fails ? :fails : :success) if ResourceController::FAILABLE_ACTIONS.include? action.first
66
+
67
+ options
68
+ end
69
+
70
+ def invoke_callbacks(*callbacks)
71
+ unless callbacks.empty?
72
+ callbacks.select { |callback| callback.is_a? Symbol }.each { |symbol| send(symbol) }
64
73
 
65
- options
74
+ block = callbacks.detect { |callback| callback.is_a? Proc }
75
+ instance_eval &block unless block.nil?
76
+ end
77
+ end
66
78
  end
67
-
68
- def invoke_callbacks(*callbacks)
69
- unless callbacks.empty?
70
- callbacks.select { |callback| callback.is_a? Symbol }.each { |symbol| send(symbol) }
71
-
72
- block = callbacks.detect { |callback| callback.is_a? Proc }
73
- instance_eval &block unless block.nil?
74
- end
75
- end
79
+ end
76
80
  end
@@ -1,63 +1,67 @@
1
1
  # Nested and Polymorphic Resource Helpers
2
2
  #
3
- module ResourceController::Helpers::Nested
4
- protected
5
- # Returns the relevant association proxy of the parent. (i.e. /posts/1/comments # => @post.comments)
6
- #
7
- def parent_association
8
- @parent_association ||= parent_object.send(model_name.to_s.pluralize.to_sym)
9
- end
3
+ module ResourceController
4
+ module Helpers
5
+ module Nested
6
+ protected
7
+ # Returns the relevant association proxy of the parent. (i.e. /posts/1/comments # => @post.comments)
8
+ #
9
+ def parent_association
10
+ @parent_association ||= parent_object.send(model_name.to_s.pluralize.to_sym)
11
+ end
10
12
 
11
- # Returns the type of the current parent
12
- #
13
- def parent_type
14
- @parent_type ||= parent_type_from_params || parent_type_from_request
15
- end
13
+ # Returns the type of the current parent
14
+ #
15
+ def parent_type
16
+ @parent_type ||= parent_type_from_params || parent_type_from_request
17
+ end
16
18
 
17
- # Returns the type of the current parent extracted from params
18
- #
19
- def parent_type_from_params
20
- [*belongs_to].find { |parent| !params["#{parent}_id".to_sym].nil? }
21
- end
19
+ # Returns the type of the current parent extracted from params
20
+ #
21
+ def parent_type_from_params
22
+ [*belongs_to].find { |parent| !params["#{parent}_id".to_sym].nil? }
23
+ end
22
24
 
23
- # Returns the type of the current parent extracted form a request path
24
- #
25
- def parent_type_from_request
26
- [*belongs_to].find { |parent| request.path.split('/').include? parent.to_s }
27
- end
25
+ # Returns the type of the current parent extracted form a request path
26
+ #
27
+ def parent_type_from_request
28
+ [*belongs_to].find { |parent| request.path.split('/').include? parent.to_s }
29
+ end
28
30
 
29
- # Returns true/false based on whether or not a parent is present.
30
- #
31
- def parent?
32
- !parent_type.nil?
33
- end
31
+ # Returns true/false based on whether or not a parent is present.
32
+ #
33
+ def parent?
34
+ !parent_type.nil?
35
+ end
34
36
 
35
- # Returns true/false based on whether or not a parent is a singleton.
36
- #
37
- def parent_singleton?
38
- !parent_type_from_request.nil?
39
- end
37
+ # Returns true/false based on whether or not a parent is a singleton.
38
+ #
39
+ def parent_singleton?
40
+ !parent_type_from_request.nil? && parent_type_from_params.nil?
41
+ end
40
42
 
41
- # Returns the current parent param, if there is a parent. (i.e. params[:post_id])
42
- def parent_param
43
- params["#{parent_type}_id".to_sym]
44
- end
43
+ # Returns the current parent param, if there is a parent. (i.e. params[:post_id])
44
+ def parent_param
45
+ params["#{parent_type}_id".to_sym]
46
+ end
45
47
 
46
- # Like the model method, but for a parent relationship.
47
- #
48
- def parent_model
49
- parent_type.to_s.camelize.constantize
50
- end
48
+ # Like the model method, but for a parent relationship.
49
+ #
50
+ def parent_model
51
+ parent_type.to_s.camelize.constantize
52
+ end
51
53
 
52
- # Returns the current parent object if a parent object is present.
53
- #
54
- def parent_object
55
- parent? && !parent_singleton? ? parent_model.find(parent_param) : nil
56
- end
54
+ # Returns the current parent object if a parent object is present.
55
+ #
56
+ def parent_object
57
+ parent? && !parent_singleton? ? parent_model.find(parent_param) : nil
58
+ end
57
59
 
58
- # If there is a parent, returns the relevant association proxy. Otherwise returns model.
59
- #
60
- def end_of_association_chain
61
- parent? ? parent_association : model
60
+ # If there is a parent, returns the relevant association proxy. Otherwise returns model.
61
+ #
62
+ def end_of_association_chain
63
+ parent? ? parent_association : model
64
+ end
62
65
  end
66
+ end
63
67
  end
@@ -2,59 +2,63 @@
2
2
  #
3
3
  # Used internally to transform a plural RESTful controller into a singleton
4
4
  #
5
- module ResourceController::Helpers::SingletonCustomizations
6
- def self.included(subclass)
7
- subclass.class_eval do
8
- methods_to_undefine = [:param, :index, :collection, :load_collection, :collection_url,
9
- :collection_path, :hash_for_collection_url, :hash_for_collection_path]
10
- methods_to_undefine.each { |method| undef_method(method) if method_defined? method }
5
+ module ResourceController
6
+ module Helpers
7
+ module SingletonCustomizations
8
+ def self.included(subclass)
9
+ subclass.class_eval do
10
+ methods_to_undefine = [:param, :index, :collection, :load_collection, :collection_url,
11
+ :collection_path, :hash_for_collection_url, :hash_for_collection_path]
12
+ methods_to_undefine.each { |method| undef_method(method) if method_defined? method }
11
13
 
12
- class << self
13
- def singleton?
14
- true
14
+ class << self
15
+ def singleton?
16
+ true
17
+ end
18
+ end
15
19
  end
16
20
  end
17
- end
18
- end
19
21
 
20
- protected
21
- # Used to fetch the current object in a singleton controller.
22
- #
23
- # By defult this method is able to fetch the current object for resources nested with the :has_one association only. (i.e. /users/1/image # => @user.image)
24
- # In other cases you should override this method and provide your custom code to fetch a singleton resource object, like using a session hash.
25
- #
26
- # class AccountsController < ResourceController::Singleton
27
- # private
28
- # def object
29
- # @object ||= Account.find(session[:account_id])
30
- # end
31
- # end
32
- #
33
- def object
34
- @object ||= parent? ? end_of_association_chain : nil
35
- end
22
+ protected
23
+ # Used to fetch the current object in a singleton controller.
24
+ #
25
+ # By defult this method is able to fetch the current object for resources nested with the :has_one association only. (i.e. /users/1/image # => @user.image)
26
+ # In other cases you should override this method and provide your custom code to fetch a singleton resource object, like using a session hash.
27
+ #
28
+ # class AccountsController < ResourceController::Singleton
29
+ # private
30
+ # def object
31
+ # @object ||= Account.find(session[:account_id])
32
+ # end
33
+ # end
34
+ #
35
+ def object
36
+ @object ||= parent? ? end_of_association_chain : nil
37
+ end
36
38
 
37
- # Returns the :has_one association proxy of the parent. (i.e. /users/1/image # => @user.image)
38
- #
39
- def parent_association
40
- @parent_association ||= parent_object.send(model_name.to_sym)
41
- end
39
+ # Returns the :has_one association proxy of the parent. (i.e. /users/1/image # => @user.image)
40
+ #
41
+ def parent_association
42
+ @parent_association ||= parent_object.send(model_name.to_sym)
43
+ end
42
44
 
43
- # Used internally to provide the options to smart_url in a singleton controller.
44
- #
45
- def object_url_options(action_prefix = nil, alternate_object = nil)
46
- [action_prefix] + namespaces + [parent_url_options, route_name.to_sym]
47
- end
45
+ # Used internally to provide the options to smart_url in a singleton controller.
46
+ #
47
+ def object_url_options(action_prefix = nil, alternate_object = nil)
48
+ [action_prefix] + namespaces + [parent_url_options, route_name.to_sym]
49
+ end
48
50
 
49
- # Builds the object, but doesn't save it, during the new, and create action.
50
- #
51
- def build_object
52
- @object ||= singleton_build_object_base.send parent? ? "build_#{model_name}".to_sym : :new, object_params
53
- end
51
+ # Builds the object, but doesn't save it, during the new, and create action.
52
+ #
53
+ def build_object
54
+ @object ||= singleton_build_object_base.send parent? ? "build_#{model_name}".to_sym : :new, object_params
55
+ end
54
56
 
55
- # Singleton controllers don't build off of association proxy, so we can't use end_of_association_chain here
56
- #
57
- def singleton_build_object_base
58
- parent? ? parent_object : model
57
+ # Singleton controllers don't build off of association proxy, so we can't use end_of_association_chain here
58
+ #
59
+ def singleton_build_object_base
60
+ parent? ? parent_object : model
61
+ end
59
62
  end
63
+ end
60
64
  end
@@ -37,92 +37,96 @@
37
37
  #
38
38
  # You get the idea. Everything is automagical! All parameters are inferred.
39
39
  #
40
- module ResourceController::Helpers::Urls
41
- protected
42
- ['', 'edit_'].each do |type|
43
- symbol = type.blank? ? nil : type.gsub(/_/, '').to_sym
40
+ module ResourceController
41
+ module Helpers
42
+ module Urls
43
+ protected
44
+ ['', 'edit_'].each do |type|
45
+ symbol = type.blank? ? nil : type.gsub(/_/, '').to_sym
44
46
 
45
- define_method("#{type}object_url") do |*alternate_object|
46
- smart_url *object_url_options(symbol, alternate_object.first)
47
- end
47
+ define_method("#{type}object_url") do |*alternate_object|
48
+ smart_url *object_url_options(symbol, alternate_object.first)
49
+ end
48
50
 
49
- define_method("#{type}object_path") do |*alternate_object|
50
- smart_path *object_url_options(symbol, alternate_object.first)
51
- end
51
+ define_method("#{type}object_path") do |*alternate_object|
52
+ smart_path *object_url_options(symbol, alternate_object.first)
53
+ end
52
54
 
53
- define_method("hash_for_#{type}object_url") do |*alternate_object|
54
- hash_for_smart_url *object_url_options(symbol, alternate_object.first)
55
- end
55
+ define_method("hash_for_#{type}object_url") do |*alternate_object|
56
+ hash_for_smart_url *object_url_options(symbol, alternate_object.first)
57
+ end
56
58
 
57
- define_method("hash_for_#{type}object_path") do |*alternate_object|
58
- hash_for_smart_path *object_url_options(symbol, alternate_object.first)
59
- end
60
- end
59
+ define_method("hash_for_#{type}object_path") do |*alternate_object|
60
+ hash_for_smart_path *object_url_options(symbol, alternate_object.first)
61
+ end
62
+ end
61
63
 
62
- def new_object_url
63
- smart_url *new_object_url_options
64
- end
64
+ def new_object_url
65
+ smart_url *new_object_url_options
66
+ end
65
67
 
66
- def new_object_path
67
- smart_path *new_object_url_options
68
- end
68
+ def new_object_path
69
+ smart_path *new_object_url_options
70
+ end
69
71
 
70
- def hash_for_new_object_url
71
- hash_for_smart_url *new_object_url_options
72
- end
72
+ def hash_for_new_object_url
73
+ hash_for_smart_url *new_object_url_options
74
+ end
73
75
 
74
- def hash_for_new_object_path
75
- hash_for_smart_path *new_object_url_options
76
- end
76
+ def hash_for_new_object_path
77
+ hash_for_smart_path *new_object_url_options
78
+ end
77
79
 
78
- def collection_url
79
- smart_url *collection_url_options
80
- end
80
+ def collection_url
81
+ smart_url *collection_url_options
82
+ end
81
83
 
82
- def collection_path
83
- smart_path *collection_url_options
84
- end
84
+ def collection_path
85
+ smart_path *collection_url_options
86
+ end
85
87
 
86
- def hash_for_collection_url
87
- hash_for_smart_url *collection_url_options
88
- end
88
+ def hash_for_collection_url
89
+ hash_for_smart_url *collection_url_options
90
+ end
89
91
 
90
- def hash_for_collection_path
91
- hash_for_smart_path *collection_url_options
92
- end
92
+ def hash_for_collection_path
93
+ hash_for_smart_path *collection_url_options
94
+ end
93
95
 
94
- # Used internally to provide the options to smart_url from Urligence.
95
- #
96
- def collection_url_options
97
- namespaces + [parent_url_options, route_name.to_s.pluralize.to_sym]
98
- end
96
+ # Used internally to provide the options to smart_url from Urligence.
97
+ #
98
+ def collection_url_options
99
+ namespaces + [parent_url_options, route_name.to_s.pluralize.to_sym]
100
+ end
99
101
 
100
- # Used internally to provide the options to smart_url from Urligence.
101
- #
102
- def object_url_options(action_prefix = nil, alternate_object = nil)
103
- [action_prefix] + namespaces + [parent_url_options, [route_name.to_sym, alternate_object || object]]
104
- end
102
+ # Used internally to provide the options to smart_url from Urligence.
103
+ #
104
+ def object_url_options(action_prefix = nil, alternate_object = nil)
105
+ [action_prefix] + namespaces + [parent_url_options, [route_name.to_sym, alternate_object || object]]
106
+ end
105
107
 
106
- # Used internally to provide the options to smart_url from Urligence.
107
- #
108
- def new_object_url_options
109
- [:new] + namespaces + [parent_url_options, route_name.to_sym]
110
- end
108
+ # Used internally to provide the options to smart_url from Urligence.
109
+ #
110
+ def new_object_url_options
111
+ [:new] + namespaces + [parent_url_options, route_name.to_sym]
112
+ end
111
113
 
112
- def parent_url_options
113
- if parent?
114
- parent_singleton? ? parent_type.to_sym : [parent_type.to_sym, parent_object]
115
- else
116
- nil
117
- end
118
- end
114
+ def parent_url_options
115
+ if parent?
116
+ parent_singleton? ? parent_type.to_sym : [parent_type.to_sym, parent_object]
117
+ else
118
+ nil
119
+ end
120
+ end
119
121
 
120
- # Returns all of the current namespaces of the current controller, symbolized, in array form.
121
- #
122
- def namespaces
123
- names = self.class.name.split("::")
124
- names.pop
122
+ # Returns all of the current namespaces of the current controller, symbolized, in array form.
123
+ #
124
+ def namespaces
125
+ names = self.class.name.split("::")
126
+ names.pop
125
127
 
126
- names.map(&:underscore).map(&:to_sym)
128
+ names.map(&:underscore).map(&:to_sym)
129
+ end
127
130
  end
131
+ end
128
132
  end
@@ -1,4 +1,5 @@
1
1
  class Photo < ActiveRecord::Base
2
2
  has_and_belongs_to_many :tags
3
3
  belongs_to :user, :class_name => "Account", :foreign_key => "account_id"
4
+ belongs_to :personnel
4
5
  end
@@ -5,7 +5,7 @@
5
5
  # ENV['RAILS_ENV'] ||= 'production'
6
6
 
7
7
  # Specifies gem version of Rails to use when vendor/rails is not present
8
- RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
8
+ RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
9
9
 
10
10
  # Bootstrap the Rails environment, frameworks, and default configuration
11
11
  require File.join(File.dirname(__FILE__), 'boot')
@@ -45,20 +45,3 @@ Rails::Initializer.run do |config|
45
45
 
46
46
  config.action_controller.session = { :session_key => "_myapp_session", :secret => "6c1372e61789239a727cdbc8252eb6da" }
47
47
  end
48
-
49
- require "#{RAILS_ROOT}/../init"
50
-
51
- # Add new inflection rules using the following format
52
- # (all these examples are active by default):
53
- # Inflector.inflections do |inflect|
54
- # inflect.plural /^(ox)$/i, '\1en'
55
- # inflect.singular /^(ox)en/i, '\1'
56
- # inflect.irregular 'person', 'people'
57
- # inflect.uncountable %w( fish sheep )
58
- # end
59
-
60
- # Add new mime types for use in respond_to blocks:
61
- # Mime::Type.register "text/richtext", :rtf
62
- # Mime::Type.register "application/x-mobile", :mobile
63
-
64
- # Include your application configuration below
@@ -20,6 +20,9 @@ ActionController::Routing::Routes.draw do |map|
20
20
 
21
21
  map.namespace :cms do |cms|
22
22
  cms.resources :products, :has_many => :options
23
+ cms.resources :personnel do |personnel|
24
+ personnel.resources :photos
25
+ end
23
26
  end
24
27
 
25
28
  map.resources :posts do |post|
data/test/db/schema.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated from the current state of the database. Instead of editing this file,
2
- # please use the migrations feature of ActiveRecord to incrementally modify your database, and
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
3
3
  # then regenerate this schema definition.
4
4
  #
5
5
  # Note that this schema.rb definition is the authoritative source for your database schema. If you need
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # It's strongly recommended to check this file into your version control system.
11
11
 
12
- ActiveRecord::Schema.define(:version => 12) do
12
+ ActiveRecord::Schema.define(:version => 14) do
13
13
 
14
14
  create_table "accounts", :force => true do |t|
15
15
  t.string "name"
@@ -33,9 +33,15 @@ ActiveRecord::Schema.define(:version => 12) do
33
33
  t.string "title"
34
34
  end
35
35
 
36
+ create_table "personnel", :force => true do |t|
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
+ end
40
+
36
41
  create_table "photos", :force => true do |t|
37
42
  t.string "title"
38
43
  t.integer "account_id"
44
+ t.integer "personnel_id"
39
45
  end
40
46
 
41
47
  create_table "photos_tags", :force => true do |t|
@@ -45,7 +51,7 @@ ActiveRecord::Schema.define(:version => 12) do
45
51
 
46
52
  create_table "posts", :force => true do |t|
47
53
  t.string "title", :default => ""
48
- t.text "body"
54
+ t.text "body", :default => ""
49
55
  end
50
56
 
51
57
  create_table "products", :force => true do |t|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nileshtrivedi-lp_resource_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Golick
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-09-03 21:00:00 -07:00
13
+ date: 2008-10-16 21:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16