Skip to content

Instantly share code, notes, and snippets.

@flakd
Forked from Amitesh/gist:1723426
Created July 3, 2013 06:17
Show Gist options
  • Select an option

  • Save flakd/5915810 to your computer and use it in GitHub Desktop.

Select an option

Save flakd/5915810 to your computer and use it in GitHub Desktop.
# http://rails-bestpractices.com/posts/48-use-openstruct-when-advance-search
class Tableless
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def initialize(props = {})
props.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
end
class Search < Tableless
validates :quick, :presence => true
end
def index
@search = Search.new(params[:search])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment