I knew what I was attempting wasnt a very good idea.  I just wasnt sure 
what to do inside the apply_filter method, for example, where I set the 
dataset = dataset.where...
Inside the dataset_module, would that just be self = self.where(.....)?

    # Apply criteria to dataset
    filter_criteria.each do |attribute_name|
      attribute_value = "#{params[attribute_name].gsub('*','%')}%"
      dataset = dataset.where(Sequel.like(attribute_name.to_sym, 
attribute_value))
    end


On Friday, August 9, 2013 1:42:50 PM UTC-5, Jeremy Evans wrote:
>
> On Friday, August 9, 2013 9:55:51 AM UTC-7, Keith Moore wrote:
>>
>> Maybe this gives you a better idea of what I am trying to do.  My current 
>> approach in the other methods is to pass in the dataset.  When I tried to 
>> set the dataset, I was corrupting the original dataset attribute on the 
>> Model.  That is why I was trying to clone it. 
>>
>
> You don't want to be modifying a model's dataset or cloning a model class 
> at runtime.  Looking over your code I can't see a reason that using a 
> dataset method as showed an example of earlier wouldn't meet your need.  
> What is the reason you are trying to modify/clone a model, where working 
> with a clone of the model's dataset would be insufficient?
>
> Looking at this code specifically:
>
>     filtered_dataset = NetworkObject.apply_filter(params)
>     filtered_dataset = filtered_dataset.where(:NODE_STATUS_ID => 1, 
> :OBJECT_STATUS_ID => 1)
>     @network_objects = NetworkObject.apply_pagination(filtered_dataset, 
> params[:_startRow], params[:_endRow], "name").all
>
> Why wouldn't you just define your dataset methods (inside dataset_module) 
> such that you can do:
>
>   @network_objects = NetworkObject.apply_filter(params).
>     where(:NODE_STATUS_ID => 1, :OBJECT_STATUS_ID => 1).
>     apply_pagination(params[:_startRow], params[:_endRow], "name").all
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to