0

I am using a scope to filter my results :

@hotels = @hotels.type(params[:hotel_type]) unless params[:hotel_type].blank?

with

scope :type, lambda { |type|
  self.scoped.where('hotel_type_id IN ( ? )', type.join(', ')) unless type.blank?
}

And params[:hotel_type] = ["2","3"]

Anyone can help me? I think it's because it's an array but i don't know how to fix this.

Thank you

1
  • You should be able pass in type without the join because the SQL escaping should take care of it for you. Commented Sep 30, 2011 at 15:16

1 Answer 1

4

i think you cant name your scope type, i'd name it by_type

Sign up to request clarification or add additional context in comments.

4 Comments

Sometimes reserved words sneak up and bite you like this.
Yes, i didn't think so but it seems logical!
Yesterday I tried to name a column 'type' and that didn't work either.
Type is used in single table inheritance to name a attribute in order to use same table for diff classes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.