Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed for Mongoid 2 support

  • Loading branch information...
commit 2f8c47a46f4276fa155b85e911d7a1a543de28a3 1 parent a53363d
John Maxwell authored
1  lib/generators/impressionist_generator.rb
View
@@ -7,6 +7,7 @@ class ImpressionistGenerator < Rails::Generators::Base
def copy_config_file
template 'impression.rb', 'config/initializers/impression.rb'
end
+
end
end
end
1  lib/generators/templates/impression-mongoid-2.rb
View
@@ -0,0 +1 @@
+impression-mongoid-2.rb
3  lib/impressionist/controllers/mongoid/impressionist_controller.rb
View
@@ -1,9 +1,10 @@
ImpressionistController::InstanceMethods.send(:define_method, :direct_create_statement) do |query_params={}|
# creates a statment hash that contains default values for creating an impression.
# if :impressionable_id is a valid ObjectId then convert it into one
+ base = (defined? Moped) ? Moped::BSON : BSON
query_params.reverse_merge!(
:impressionable_type => controller_name.singularize.camelize,
- :impressionable_id=> !Moped::BSON::ObjectId.legal?(params[:id]) ? params[:id] : Moped::BSON::ObjectId.from_string(params[:id])
+ :impressionable_id=> !base::ObjectId.legal?(params[:id]) ? params[:id] : base::ObjectId.from_string(params[:id])
)
associative_create_statement(query_params)
end
10 lib/impressionist/controllers/mongoid/mongoid2-impressionist_controller.rb
View
@@ -0,0 +1,10 @@
+ImpressionistController::InstanceMethods.send(:define_method, :direct_create_statement) do |query_params={}|
+ # creates a statment hash that contains default values for creating an impression.
+ # if :impressionable_id is a valid ObjectId then convert it into one
+ base = (defined? Moped) ? Moped::BSON :: BSON
+ query_params.reverse_merge!(
+ :impressionable_type => controller_name.singularize.camelize,
+ :impressionable_id=> !base::ObjectId.legal?(params[:id]) ? params[:id] : base::ObjectId.from_string(params[:id])
+ )
+ associative_create_statement(query_params)
+end
Please sign in to comment.
Something went wrong with that request. Please try again.