lib/dynamic_models.rb
def parent_model
    params.each do |name, value|
      if name =~ /(.+)_id$/
        return @parent_model ||= $1.camelize.constantize.find(value)
      end
    end
    nil
  end
# looks for object_id notation, and returns a new model
looks for object_id notation, and returns a new model
looks for object_id notation and returns a new model
def parent_model
    params.each do |name, value|
      if name =~ /(.+)_id$/
        return @parent_model ||= $1.camelize.constantize.find(value)
      end
    end
    nil
  end
def parent_model params . each do | name , value | if name =~ / (.+)_id$ / return @parent_model ||= $1 . camelize . constantize . find ( value ) end end nil end
looks for object_id notation, and returns a new model
looks for object_id notation and returns a new model