Class: Admin::LinkablesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::LinkablesController
- Defined in:
- app/controllers/admin/linkables_controller.rb
Instance Method Summary collapse
Instance Method Details
#fields ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/admin/linkables_controller.rb', line 26 def fields @linkable = Linkable.get(params[:type]) @target = params[:target] @field_name = params[:field_name] if params[:current_type].present? && params[:current_id].present? @currently_linked = Linkable.get(params[:current_type]).find(params[:current_id]) end end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/admin/linkables_controller.rb', line 4 def index term = params[:term] type = params[:type] resp = {} if term && term.size > 3 && (linkable = Linkable.get(type)) column = :"#{title_column(linkable)}" linkable.where( linkable.arel_table[column].matches("%#{term}%") ).select([:id, column]).each do |l| resp[l.id] = l.send(column) end end render :json => resp end |