fixed for Mongoid 2 support
This commit is contained in:
parent
a53363d9f6
commit
2f8c47a46f
|
@ -7,6 +7,7 @@ module Impressionist
|
|||
def copy_config_file
|
||||
template 'impression.rb', 'config/initializers/impression.rb'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
impression-mongoid-2.rb
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue