Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Model < ActiveRecord::Base
- def update_from_params(params)
- ....
- end
- end
- class ModelsController < ActionController::Base
- def update
- ...
- @model.update_from_params(params)
- end
- end
- class Model < ActiveRecord::Base
- def update_from_update_params(params)
- # do stuff
- end
- def update_from_settings_params(params)
- # do different stuff
- end
- end
- class ModelsController < ActionController::Base
- def update
- ...
- @model.update_from_update_params(params)
- end
- def change_settings
- ...
- @model.update_from_settings_params(params)
- end
- end
- class Model < ActiveRecord::Base
- def update_from_data(hash)
- validate_data!(hash)
- # do stuff
- end
- end
- class ModelsController < ActionController::Base
- def update
- ...
- @model.update_from_data(translate_update_params)
- end
- def change_settings
- ...
- @model.update_from_data(translate_change_settings_params)
- end
- end
- # in controller
- def search
- Model.search(params[:search][:options])
- end
- <!-- in view -->
- <input type='text' name='search[options][keywords]' />
- <input type='text' name='search[options][conditions]' />
- <input type='text' name='search[options][sort]' />
- def self.do_search(criteria)
- Rental.search(criteria[:keywords],
- :per_page => self.per_page,
- :page => page,
- :conditions => criteria[:conditions],
- :order => criteria[:sort])
- end
- def self.do_search(keyword,params)
- Rental.search(keyword,
- :per_page => self.per_page,
- :page => page,
- :conditions => will_condition(params),
- :order => will_sort(params))
- end
- @@searchable_fields = ['property_status_id', 'neighborhood_id', 'borough_id', 'number_of_bedrooms']
- cattr_reader :searchable_fields
- @@sortable_fields = ['number_of_bedrooms','rent','street_address']
- cattr_reader :sortable_fields
Add Comment
Please, Sign In to add comment