token_field 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +142 -84
- data/Rakefile +11 -19
- data/lib/token_field/capybara/dsl.rb +2 -1
- data/lib/token_field/engine.rb +0 -4
- data/lib/token_field/form_builder.rb +18 -20
- data/lib/token_field/simple_form/token_input.rb +9 -2
- data/lib/token_field/version.rb +1 -1
- data/spec/dummy/app/controllers/categories_controller.rb +13 -4
- data/spec/dummy/app/controllers/items_controller.rb +8 -2
- data/spec/dummy/app/controllers/products_controller.rb +8 -2
- data/spec/dummy/app/models/category.rb +2 -3
- data/spec/dummy/app/models/item.rb +0 -2
- data/spec/dummy/app/models/product.rb +0 -1
- data/spec/dummy/app/models/product_has_category.rb +0 -2
- data/spec/dummy/config/application.rb +2 -6
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/development.rb +3 -7
- data/spec/dummy/config/environments/production.rb +4 -5
- data/spec/dummy/config/environments/test.rb +4 -4
- data/spec/dummy/config/initializers/strong_parameters.rb +5 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1084 -0
- data/spec/dummy/log/test.log +33351 -0
- data/spec/dummy/tmp/cache/assets/C4F/BA0/sprockets%2F5b842030b744954247b274d6b0d93f82 +0 -0
- data/spec/dummy/tmp/cache/assets/C50/830/sprockets%2Fc2b655a6a30432b76933792e517f5291 +0 -0
- data/spec/dummy/tmp/cache/assets/C68/F70/sprockets%2F03000591510dc6784ee531c103e66a7a +0 -0
- data/spec/dummy/tmp/cache/assets/C82/490/sprockets%2F2cea86012965b76f28b56b4522099f12 +0 -0
- data/spec/dummy/tmp/cache/assets/CCB/5D0/sprockets%2F2b021b5261218f4183021778bade6ddd +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CE1/B10/sprockets%2Fdced6804c57d3153294a01249ef867d0 +0 -0
- data/spec/dummy/tmp/cache/assets/CE4/CC0/sprockets%2F8c39c0da3443b6824828ee0e2297f2e3 +0 -0
- data/spec/dummy/tmp/cache/assets/D0F/700/sprockets%2Fb728373cb12011fa141dfc9a8386ef89 +0 -0
- data/spec/dummy/tmp/cache/assets/D10/FF0/sprockets%2F47a90636516eb46fc041d91c9be84b0f +0 -0
- data/spec/dummy/tmp/cache/assets/D2B/9F0/sprockets%2F573dcce95926d7e95dc3e7486716e41d +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D3E/1E0/sprockets%2Fd3e4a0e0e469d4f2099f2991fc52bd10 +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D56/E40/sprockets%2F55ac91700fc21cbc019fea2d206a16c8 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D7F/9E0/sprockets%2Fd984f45a60778c3cf14f1df92b0d9e6d +0 -0
- data/spec/dummy/tmp/cache/assets/DA5/100/sprockets%2F7d657d1d3bce59d08ee0cf74f16086ba +0 -0
- data/spec/dummy/tmp/cache/assets/DAC/370/sprockets%2F03a081dc7732cd2c4cbb10a57caa43ec +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/E08/1C0/sprockets%2F686aa3aefb69a744730f9dfebc0d4c9e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2rD-NbfxL41ovM9Xofx6JQnSfJ1YMdzIYmeSGzqgjMk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/32VeAROUnaUkDhGuqKLXloInm3fe9_fjTbooXOx57XM.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/3DagTfgMVVb9JxBG4iLcliCa_kH0l9M0SAhzNCCBfQQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/48sb06ouBRT3bY-BupXDnd5qXrQrJYYYbAXkTBuI0a8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/6JDNR9zD4DtjzFf1hyPiiEon9u_4q-kv2hKkbSTOKoY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/8ULBNlT8C1Gc_sDisSvQ-cQOaOTmLgEyaB8uM_W6WoI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/A3QwKX3xKGHDk5tMn8k9HI6cyc18PVR9gvMxTQOb1tw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Ag-9zUKUAUzhaNKuJhbaGtA_BfsCD3h7HW9F4G3AYi0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/B5fzn4fNu7aOnX-IAVTHav_uDU0JusddQ-66VHDOGeg.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/CWvkNWfDB2V38zgTquIZJL8Qe5lp6vIOTe0_z8Xl3Q4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/FYBkOwqnWjX-yaysXWh-8IkF6LTmhwYOrDYeeLZ3dlk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/JNp79x7ZpgHwaunFoF4dv1sGIguB6wRd_6RQcnmz8kY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Jx6P6ixJ_j1uk3Mj1icIc2tQT073xzCvTOBu2q8m-Sc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/KaajLDBcc-77MXLcThHHyjT1-4IPpcPOLAxDIsFxjXs.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Lzl9vE-V9xIya_3axcQHEWd3YNq2Tf3koCy3y_9o_yw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OYgl4AqQ-q2VErerOAM-WigjIi7rpYZ3MIxuFIgTmF4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/QsXmO1yQTZpNDvaQmVHJhkzFQN0bM_28ON1GzOZgWec.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UlxRCT-rTDSEhDN3bfyQBAXSFrQWp2mlKCAS2HETcIY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/W6sszOgRxSPAvmmgpsGDb-u0a5nk32xyj0W2gqOhd3U.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Zkt3DLZYJaicRAFL-gICpW-tE8alGfVTEhe4OmjBd3A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/aAnvmFAGZ3EbIQ5RM4YXGC2n0HP0ybnC_hGd0UibKbw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/be--I6jKQ0Nsi2htKCIeLqZBsqeaikSH8RLYEi-8llw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/dmWSoZsO41NE0U2TnvucsI2YyZKB8o-jPThRqMEJMsg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/goT7oX_iTMYkLM8D6LO1Mj46F1lISf0rJuMJY5znOuk.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/h75lgYw3sFnumOyzgDrK-WX10Th4yBYJqCXBwGj0GA8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/hRrID95UB4TJT_Z-tKyRJ5jYrSctS4WbIBZkhvsNOo4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/j42cv3HfgjE2xpgLWPrunf0JpnhuKPU0clTz23NaJ6k.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kIfchbDHQ-q7DjXik59-hTJYMz_O29qF1HBFlVtGAA4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/meuB_4gO5MG7zPbC47L7yqCtIqklHCfG3fi7Lo_t-2o.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/nXwLVMSlsDyxT8qBnI-l7x3NuzvPWEvgzojgTq7jBlU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/qNUdz8c1b-Cgrs8NvON97j03sHMBVU303Px6rDpiD9A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/sL_zwz1wD0XfLf6_S6xDQ-YYWy-siUXYn-WqDXTr-5Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/sqQDYCJgpbWaWVr_MSpR67txLpocCgsxgPlY3bfe78A.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ttSzee3NzEUw4fJR-DaDHgNxB9C5v-_P7DU-5q0nWzQ.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/v_r4UTYyOGjrLPeuR9ijVULXPblSQMoj2RQxKELv7II.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/wgWNzf34hNQnH2QVgzgiToG1jjRb_EOggi4OynuhCxI.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/2PMsEYFiByU7O0WmCBT5MwPvBGqqwjTp4cPl0H5nhxM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/2UxrjR9247T7qS95VDzg3c5sSbIiryheK5DziZR-ELk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/32VeAROUnaUkDhGuqKLXloInm3fe9_fjTbooXOx57XM.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/3mg5tYlAiRxcpn2BaYYF1ROG4QCC0zz8Ez9HwzO3seA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/43Set6DYc8L9p5CNe35jGApTwPdGroBNxx8awVyt34I.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/4aPukUfFkHfe-7F4cKKjqmfYDhZPj8Twr3ldCu-DmSY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5FxT8u1nIWZlRwoew30GlRbPyfZWPemYw7O2I2E2eVQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/7OWybKVj7HP-Ps-XPg9VskDwhFJ0mV_r2wBbYiV9OTY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/8wogN7wms9kD7qD5mXzaJWSJpEuKuQfic3jUCiWyYek.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/A3QwKX3xKGHDk5tMn8k9HI6cyc18PVR9gvMxTQOb1tw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/AC7B_I-E6IcUjDVdXrkVJpQVQAtlAflyODbpJAQa254.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/AEJzHztdSFs3riKL1JWyf4TxdTBMj76hIcSMJ4e5zFM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Ag-9zUKUAUzhaNKuJhbaGtA_BfsCD3h7HW9F4G3AYi0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/B5fzn4fNu7aOnX-IAVTHav_uDU0JusddQ-66VHDOGeg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/BydltyRa-wg1QS0OmxXH3GWdgM5RGsKykkz85aj09Ew.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/CWvkNWfDB2V38zgTquIZJL8Qe5lp6vIOTe0_z8Xl3Q4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/CXPSxI0dfV9CRI7CJvyA9LMofi3oHiZOxgZZTJArK9U.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ClXeNs3e0mcYEcldY5k8ovzFSdWgt2bgjfrr59nMV3k.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Dwo1k_n7pePnttDEp_W216_MJ-PY_DcIBTiK3gPzGyA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/DwuHLwTCZWGEMcda-ZFA545ebYglTK19r5DLbcI1_Ww.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/EGoWVjwvSBGioUIVwMBewFuXzQnWnyGjLL93eLYAijw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/EkAATpfUxLtE5hjmldaQ9AXgSGnL6IxPWRXbVArpi0Y.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/GubZLYRhsFZialV6g37NwU0IfZlR5XRZM70_tyadOg4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HVas6MQEkZ21ydsdrXDmhQj0OVfkjKmejJaHrsMhQWw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HZPH02ZLOslpuEko2k_loExL33bs6Vv8LYTAPoyywSA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/HzkJchCHtrEDvV4HRAbhXNcotyTfszQF4bj5Tg5bLcM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/JNp79x7ZpgHwaunFoF4dv1sGIguB6wRd_6RQcnmz8kY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/K8u_E6ZeuVnfBagZmruN-vp6yT-ZslaJg0ij9koiVOI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/KaajLDBcc-77MXLcThHHyjT1-4IPpcPOLAxDIsFxjXs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/LdIdja4QFlpJrJouR0TKiGxJ44PPf5bg73S3AyolZPs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/LiXd-XkCu_zzxEM56rf9Tr8dWsCeDRk3OmRoGQeztw0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/M4Yukv2yPTqN-q2g7qzwnEDxm1tiTB8tfRZdJd2BUBg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Mm3pl51V8EAzi1XRMY2rloMi51uz9q33A-d7HzrS_v4.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/N2PqLZf6dTvu4ZEqGt7DLGKDRluBNkFOx7HE521Nk08.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/OPHQPCVybpmyrpG-qH8wPxv_X_CxCxaA-uduQnP2Qqo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/OYgl4AqQ-q2VErerOAM-WigjIi7rpYZ3MIxuFIgTmF4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/QWoJs1ubrNrl9naTIounYhByDHKv1-AgVElHHE_lub0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/RyrOK8FHFiMxv1_D4AvoDkfOw513w40PrpCIbykzPq4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/T5FQV1xkXT1_yF34lXEaKxtrSdheHZXPRAxEFXf_ybE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/TAYZad6l_w-rKQ3uxMyxc0PXle0z7gmzIZbDVCc38O0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/UlxRCT-rTDSEhDN3bfyQBAXSFrQWp2mlKCAS2HETcIY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/V8zrq2aOTP1USFMzzIfa-7X8A7pMMxnXi7Mdt0d6o74.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Vw4XMLemXAmeIx3RCtgaN7yXWNH4yekzKWOu_VcPMAM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/W6sszOgRxSPAvmmgpsGDb-u0a5nk32xyj0W2gqOhd3U.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/WWhV6lUpBbGKFSV0E5wFdw1ayVmUQFdy_KxMHGitEjY.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/XOXNsmXWsjJ675b5V1iSWZx4187tmf9RqxTN9tE45Bo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YIZHJwrc-9zZmINXA816ubMYjdZCxRfsZnpRsuLM2GI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/YxupSbcbuQFGIa6MGDoIvdUqXCInXU9ZnhUKvVYvwKk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/Zkt3DLZYJaicRAFL-gICpW-tE8alGfVTEhe4OmjBd3A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/aAnvmFAGZ3EbIQ5RM4YXGC2n0HP0ybnC_hGd0UibKbw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/aHNenO26RH5TedeJ8cSwhjt7YWUUuV9hNcUdGoTqy5U.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/be--I6jKQ0Nsi2htKCIeLqZBsqeaikSH8RLYEi-8llw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/bmfw2RlM0hIII1Gvi2yb07QSsJPoqEXgIg33WkLHQY8.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/eL-vrfG91Ydi3fR839qe-lWT_hrBWyuxdzxI7dhCcmk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/f8sxFWJgp6Xd20Cj46d-G3mwN0C8vTlj-1zAqEHRHJ8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/fQ9ydxpe64IJbz3ydey8tLbjp3f4iT6vgK86lBwWe-s.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/fwtBCtx_UmYLfGGrwgp-_yl-E2-wgILUxrwNz7XM3JY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/goT7oX_iTMYkLM8D6LO1Mj46F1lISf0rJuMJY5znOuk.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/hieVI5ID_7eMb50UwPqU41g4ADkOfSQud-4v5WpgMzc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/hnR1_z83xbWxBMga6Yao6j0KCRgaZrHLufPbjvnVdrE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jcGhU0vX4q_sSH7WOyz6pyHxhhGjnFKzS_1hT-1eoRo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jeP79U5A28hI_vDlJyUVGpScO8TEyNL3ANAo_uW4ptc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jeo26N1rjV-rDuEwlRMZSes7MZEMWdFCLlojdIXN9MU.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/kIfchbDHQ-q7DjXik59-hTJYMz_O29qF1HBFlVtGAA4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/kV7VF9y8TRSd9d572M-Tiwiw16GFV9x0R-GPvO8CuPk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/lIVfvNIkxhqH3uVqxOvlAWVD3LrXUaHBJrL1x9S-H9g.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/lqUuCfH_d0qAJYApx4ch5ki8aidJdqnbMN-eta6oF0Q.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/mFCuIJ6CIqrcHKR4XKbMYSJVIzVfs9wTJcHaqKleKNM.cache +2 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/meuB_4gO5MG7zPbC47L7yqCtIqklHCfG3fi7Lo_t-2o.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/oH2yaWEGCOt43TtW97pxSIJ3rB4uV4yFTEjCSICgtG8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/omFfQ9zfC-WU5He9thtS1nVjTVQdk2FG6Nvc7OZKcBM.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/oqoQKM8yw6sfaEkFPxPiZC74VHANhE-f9l06ZCvcHR0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/oui3rMLHEUREhi2LbR_K4eneGSjXZdKE5jH5hKDS5qs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/pdcXUpKtx6BpMd8kf8J6X9pIa_XsDIqFFubJ9S0ld4s.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ptuiOsXyfG474j_ZodR7t3jt3BYbWRVqByZkRtEPFrM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qNUdz8c1b-Cgrs8NvON97j03sHMBVU303Px6rDpiD9A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/r5-UvyLJv7fQE_19swNC46TzvUqvwAGfh0NrTY30_VI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/sqQDYCJgpbWaWVr_MSpR67txLpocCgsxgPlY3bfe78A.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/tQHmCY8zL5xURDpa6cDTUotPaBTg48qDNMdTwzGtUt4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ttSzee3NzEUw4fJR-DaDHgNxB9C5v-_P7DU-5q0nWzQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/u66nNDkNs8kGRDmtNPvbV-4edJoJz6yRw1lNkHRH4Wg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/wgWNzf34hNQnH2QVgzgiToG1jjRb_EOggi4OynuhCxI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/xeO4Rpi3GSrsOKh8uvFUKcYjX1mMA5gkndFWZ9y20dg.cache +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/zUWIWAVmcgFqyoBjWyZGGFeglj5Js5lak_QfkdA_HmQ.cache +0 -0
- data/spec/dummy/tmp/capybara/capybara-201510261620025225892473.png +0 -0
- data/spec/dummy/tmp/capybara/capybara-201510261622495083432261.html +23 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-16-21-35.090.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-16-21-35.090.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-16-21-41.161.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-16-21-41.161.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-16-42-07.798.html +20 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-17-02-58.538.html +24 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-17-04-27.286.html +35 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-17-04-27.286.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-17-04-30.457.html +35 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-17-04-30.457.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-27.943.html +36 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-28.006.html +36 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-30.707.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-30.707.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-31.872.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-31.872.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-33.006.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-33.006.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.147.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.147.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.197.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.224.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.290.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-34.364.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-36.528.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-36.528.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-48.062.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-48.105.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-50.648.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-50.648.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-51.843.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-41-51.843.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-42-00.500.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-26-19-43-20.297.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-02.547.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-02.547.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.728.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.728.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.800.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.841.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.934.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-04.934.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-05.025.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-05.025.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-05.088.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-05.130.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-06.269.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-06.269.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-07.413.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-07.413.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-07.472.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-00-07.504.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-02.626.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-02.690.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-04.519.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-04.519.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-04.598.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-04.598.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-11.531.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-11.531.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-05-11.636.html +42 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.435.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.435.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.521.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.521.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.583.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-06-04.615.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-02.245.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-02.245.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-03.056.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-03.056.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-03.545.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-09-03.991.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-45.485.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-45.485.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-46.689.html +12 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-46.689.png +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-47.220.html +0 -0
- data/spec/dummy/tmp/capybara/screenshot_2015-10-27-15-12-47.688.html +0 -0
- data/spec/features/autocomplete_with_dynamic_url_spec.rb +65 -0
- data/spec/features/many_to_many_tree_structore_spec.rb +68 -0
- data/spec/features/model_with_static_token_url_spec.rb +66 -0
- data/spec/spec_helper.rb +7 -2
- metadata +492 -38
- data/spec/requests/categories_spec.rb +0 -68
- data/spec/requests/items_spec.rb +0 -68
- data/spec/requests/products_spec.rb +0 -70
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZTRjNjI2ZTM4Y2FkZmRmMWM4NTgxMTEwM2ZiZmZlMzJiZDdkYmMxZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 85d4b06c7b4116ae38a8e4400420b91994491213
|
4
|
+
data.tar.gz: 59d38c8bc49e6a5a19ac6dc0ceb8921f84ae6a03
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZjI3NmJiNzVkYzU1ODVhMTVhNjg3M2U1MThhODA0MzdkMmZlNzAwNzBiMzg5
|
11
|
-
NWVhOTk5YWNiMzA3ZDEyMGEwNzc1NTI5YTY2MTBlMGUyMWQ5ZGU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MjBkNTBjOGViODIxYzgwMmNlNTdiNGQxZWIyNDIwMzZlMzE4M2FkMmY0YWFj
|
14
|
-
MTllYjM0Y2VmYzI3NDJiMmI4MzYzZDVmNWU5NDgwOTY5ODQ3NmU1ZGYwNjZk
|
15
|
-
MmE5NWMzN2RiMWI4ZGIwY2I1ZmM4ZGI1MmU2M2UyOTBiN2NjMGI=
|
6
|
+
metadata.gz: b9a360736e6de51ffd39393ac2a033135fe0ea0aa3948cbe88e4905b907ce13ff3196edcc3151afeda34c19aec630041906a4f7837ba955b1aced71dbbbdd80c
|
7
|
+
data.tar.gz: 51e877060b97959eccc7f7483678fdb8290e52f87e8ff814ca68ee45ac7774c1cb1d635a46c829f0afdfbc13b93bd1013e54508a5ce86b1e1f4d504520c845a1
|
data/README.md
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
# TokenField
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/mirrec/token_field.svg?branch=master)](https://travis-ci.org/mirrec/token_field)
|
4
|
+
|
5
|
+
This gem add helper for form_for to Ruby on Rails
|
4
6
|
form_for helper for token input with jquery token input plugin
|
5
7
|
for has_many and belongs_to association
|
6
8
|
|
7
9
|
http://railscasts.com/episodes/258-token-fields
|
10
|
+
|
8
11
|
http://loopj.com/jquery-tokeninput/
|
12
|
+
|
9
13
|
https://github.com/foohey/jquery-tokeninput-rails
|
10
14
|
|
15
|
+
Supported Ruby on Rails versions:
|
16
|
+
* ~> 3.2.1
|
17
|
+
* ~> 4.0.1
|
18
|
+
* ~> 4.1.1
|
19
|
+
* ~> 4.2.1
|
20
|
+
|
11
21
|
helper will render standard text field input with javascript.
|
12
22
|
javascript will change standard input to token field input
|
13
23
|
|
@@ -15,8 +25,10 @@ javascript will change standard input to token field input
|
|
15
25
|
|
16
26
|
Add this line to your application's Gemfile:
|
17
27
|
|
18
|
-
|
19
|
-
|
28
|
+
```ruby
|
29
|
+
gem 'jquery-tokeninput-rails' # dependency
|
30
|
+
gem 'token_field'
|
31
|
+
```
|
20
32
|
|
21
33
|
And then execute:
|
22
34
|
|
@@ -38,85 +50,105 @@ usage for tree
|
|
38
50
|
|
39
51
|
we have a model Category like this
|
40
52
|
|
41
|
-
class Category < ActiveRecord::Base
|
42
|
-
attr_accessible :name, :parent_id
|
43
53
|
|
44
|
-
|
45
|
-
|
54
|
+
```ruby
|
55
|
+
class Category < ActiveRecord::Base
|
56
|
+
attr_accessible :name, :parent_id
|
46
57
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
58
|
+
has_many :categories, :foreign_key => :parent_id
|
59
|
+
belongs_to :parent, :foreign_key => :parent_id, :class_name => "Category"
|
60
|
+
|
61
|
+
# format that token input use
|
62
|
+
def to_token
|
63
|
+
{:id => id, :name => name}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
52
67
|
|
53
68
|
we have action for responding for token input ajax calls, simple autocomplete
|
54
69
|
|
55
|
-
|
70
|
+
```ruby
|
71
|
+
class CategoriesController < ApplicationController
|
56
72
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
respond_to do |format|
|
61
|
-
format.json { render :json => Category.token_json(@categories) }
|
62
|
-
end
|
63
|
-
end
|
73
|
+
# action for autocomplete
|
74
|
+
def token
|
75
|
+
categories = Category.where("categories.name like ?", "%#{params[:q]}%")
|
64
76
|
|
65
|
-
|
66
|
-
|
77
|
+
respond_to do |format|
|
78
|
+
format.json { render :json => categories.map(&:to_token) }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# rest of the class
|
83
|
+
end
|
84
|
+
```
|
67
85
|
|
68
86
|
in routes we have route for token ajax call
|
69
87
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
88
|
+
```ruby
|
89
|
+
MyApplication::Application.routes.draw do
|
90
|
+
resources :categories do
|
91
|
+
collection do
|
92
|
+
get :token # route for token -> token_categories_path
|
76
93
|
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
77
97
|
|
78
98
|
then in view we call token_field with param :model => :category
|
79
99
|
|
80
|
-
|
81
|
-
|
82
|
-
|
100
|
+
```erb
|
101
|
+
<%= form_for @category do |f| %>
|
102
|
+
<%= f.token_field :parent_id, :model => :category, :token_url => token_categories_path %>
|
103
|
+
<% end %>
|
104
|
+
```
|
83
105
|
|
84
106
|
in case model is in namespace for example MyApp you should use :model like this
|
85
107
|
|
86
|
-
|
87
|
-
|
88
|
-
|
108
|
+
```erb
|
109
|
+
<%= form_for @category do |f| %>
|
110
|
+
<%= f.token_field :parent_id, :model => "MyApp::Category", :token_url => token_categories_path %>
|
111
|
+
<% end %>
|
112
|
+
```
|
89
113
|
|
90
114
|
if you need dynamically evaluated url of token input, you can pass inline javascript function to `:token_url` options but with `:token_url_is_function` set to `true`
|
91
115
|
|
92
|
-
|
93
|
-
|
94
|
-
|
116
|
+
```erb
|
117
|
+
<%= form_for @category do |f| %>
|
118
|
+
<%= f.token_field :parent_id, :model => :category, :token_url => "function(){ return '/hello' }", :token_url_is_function => true %>
|
119
|
+
<% end %>
|
120
|
+
```
|
95
121
|
|
96
122
|
also own separate function are supported
|
97
123
|
|
98
|
-
|
99
|
-
|
100
|
-
|
124
|
+
```erb
|
125
|
+
<%= form_for @category do |f| %>
|
126
|
+
<%= f.token_field :parent_id, :model => :category, :token_url => "myDynamicUrl", :token_url_is_function => true %>
|
127
|
+
<% end %>
|
101
128
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
129
|
+
<script type="text/javascript">
|
130
|
+
function myDynamicUrl() {
|
131
|
+
return "/my-url/";
|
132
|
+
}
|
133
|
+
</script>
|
134
|
+
```
|
107
135
|
|
108
136
|
if there would be model Parent, we can omit :model parameter.
|
109
137
|
for example in Product model like this
|
110
138
|
|
111
|
-
|
112
|
-
|
113
|
-
|
139
|
+
```ruby
|
140
|
+
class Product < ActiveRecord::Base
|
141
|
+
belongs_to :category
|
142
|
+
end
|
143
|
+
```
|
114
144
|
|
115
145
|
we can use this code in view
|
116
146
|
|
117
|
-
|
118
|
-
|
119
|
-
|
147
|
+
```erb
|
148
|
+
<%= form_for @product do |f| %>
|
149
|
+
<%= f.token_field :category_id, :token_url => token_categories_path %>
|
150
|
+
<% end %>
|
151
|
+
```
|
120
152
|
|
121
153
|
helper will allow you to enter only one element.
|
122
154
|
|
@@ -126,40 +158,48 @@ We can use token_input also for mapping categories to product
|
|
126
158
|
we will use ActiveRecord method category_ids which be default return array of ids from association
|
127
159
|
in model we have to change category_ids= method like this
|
128
160
|
|
129
|
-
|
130
|
-
|
131
|
-
|
161
|
+
```ruby
|
162
|
+
class Product < ActiveRecord::Base
|
163
|
+
has_many :product_has_categories
|
164
|
+
has_many :categories, :through => :product_has_categories
|
132
165
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
166
|
+
alias_method :category_ids_old=, :category_ids=
|
167
|
+
def category_ids=(ids)
|
168
|
+
ids = ids.split(",").map(&:to_i) if ids.is_a?(String)
|
169
|
+
self.category_ids_old=ids
|
170
|
+
end
|
138
171
|
|
139
|
-
|
140
|
-
|
172
|
+
# rest of the class...
|
173
|
+
end
|
174
|
+
```
|
141
175
|
|
142
176
|
in view you will use attribute category_ids. token input will expected more than one category.
|
143
177
|
so you can enter more than one category.
|
144
178
|
|
145
|
-
|
146
|
-
|
147
|
-
|
179
|
+
```erb
|
180
|
+
<%= form_for @product do |f| %>
|
181
|
+
<%= f.token_field :category_ids, :token_url => token_categories_path %>
|
182
|
+
<% end %>
|
183
|
+
```
|
148
184
|
|
149
185
|
if you want to use multiple token inputs on page, and id of element would be the same, you can user option :append_to_id.
|
150
186
|
|
151
|
-
|
152
|
-
|
153
|
-
|
187
|
+
```erb
|
188
|
+
<%= form_for @product do |f| %>
|
189
|
+
<%= f.token_field :category_ids, :token_url => token_categories_path, :append_to_id => :id %>
|
190
|
+
<% end %>
|
191
|
+
```
|
154
192
|
|
155
193
|
if @product.id is present and for example "3" it will use this id and generate id of html input like this "product_categories_ids_3"
|
156
194
|
if @product.id is nil id of html input will be "product_categories_ids"
|
157
195
|
|
158
196
|
other value for :append_id option will be used like this
|
159
197
|
|
160
|
-
|
161
|
-
|
162
|
-
|
198
|
+
```erb
|
199
|
+
<%= form_for @product do |f| %>
|
200
|
+
<%= f.token_field :category_ids, :token_url => token_categories_path, :append_to_id => 5 %>
|
201
|
+
<% end %>
|
202
|
+
```
|
163
203
|
|
164
204
|
id of html input will be "product_categories_ids_5"
|
165
205
|
|
@@ -168,39 +208,57 @@ id of html input will be "product_categories_ids_5"
|
|
168
208
|
if you use simple_form in your project, TokenInput field will be loaded.
|
169
209
|
you can use it in view like this
|
170
210
|
|
171
|
-
|
172
|
-
|
173
|
-
|
211
|
+
```erb
|
212
|
+
<%= simple_form_for(@item) do |f| %>
|
213
|
+
<%= f.input :category_id, :as => :token, :token_url => token_categories_path %>
|
214
|
+
<% end %>
|
215
|
+
```
|
174
216
|
|
175
217
|
all options for token_field helper can be used in simple form helper as well.
|
176
218
|
|
219
|
+
## Updating from 1.x to 2.0
|
220
|
+
|
221
|
+
* Add `#to_token` method to model you are using
|
222
|
+
* Remove `.token_json` method, we don't use it anymore
|
223
|
+
* require dsl helper for tests (see below)
|
224
|
+
|
177
225
|
## Testing
|
178
226
|
|
179
227
|
add support for helpers in rspec
|
180
228
|
|
181
|
-
|
182
|
-
|
183
|
-
|
229
|
+
```ruby
|
230
|
+
require 'token_field/capybara/dsl'
|
231
|
+
|
232
|
+
RSpec.configure do |config|
|
233
|
+
config.include TokenField::Capybara::Dsl
|
234
|
+
end
|
235
|
+
```
|
184
236
|
|
185
237
|
### test helpers for capybara
|
186
238
|
|
187
239
|
filling token input
|
188
240
|
|
189
|
-
|
190
|
-
|
241
|
+
```ruby
|
242
|
+
fill_in "category_parent_id", :with => new_parent.id # standard input
|
243
|
+
fill_in_token "category_parent_id", :with => "wood"
|
244
|
+
fill_in_token "category_parent_id", :with => "wood", :waiting_call => lambda { sleep(4) }
|
245
|
+
```
|
191
246
|
|
192
247
|
clearing token input
|
193
248
|
|
194
|
-
|
249
|
+
```ruby
|
250
|
+
clear_token "category_parent_id"
|
251
|
+
```
|
195
252
|
|
196
253
|
project is covered by integration tests. using rspec, capybara and selenium
|
197
254
|
how to run test
|
198
255
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
256
|
+
```bash
|
257
|
+
bundle # install dependency
|
258
|
+
rake db:create
|
259
|
+
rake db:migrate RAILS_ENV=test
|
260
|
+
rspec spec/
|
261
|
+
```
|
204
262
|
|
205
263
|
## Contributing
|
206
264
|
|
data/Rakefile
CHANGED
@@ -1,26 +1,18 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
14
2
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake'
|
6
|
+
require 'rspec/core/rake_task'
|
22
7
|
|
23
8
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
9
|
load 'rails/tasks/engine.rake'
|
25
10
|
|
26
11
|
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
begin
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
task :default => :spec
|
17
|
+
rescue LoadError
|
18
|
+
end
|
@@ -2,8 +2,9 @@ module TokenField
|
|
2
2
|
module Capybara
|
3
3
|
module Dsl
|
4
4
|
def fill_in_token(id, options)
|
5
|
+
waiting = options.fetch(:waiting_call) { lambda { sleep(1) } }
|
5
6
|
fill_in "token-input-#{input_id(id, options)}", options
|
6
|
-
|
7
|
+
waiting.call
|
7
8
|
find(".token-input-dropdown-facebook li").click
|
8
9
|
end
|
9
10
|
|
data/lib/token_field/engine.rb
CHANGED
@@ -19,8 +19,8 @@ module TokenField
|
|
19
19
|
# has_many :products
|
20
20
|
#
|
21
21
|
# # method for converting array of categories to array of hashes in format that token input accepts
|
22
|
-
# def
|
23
|
-
#
|
22
|
+
# def to_token
|
23
|
+
# {:id => id, :name => name}
|
24
24
|
# end
|
25
25
|
# end
|
26
26
|
#
|
@@ -34,9 +34,10 @@ module TokenField
|
|
34
34
|
#
|
35
35
|
# # action for autocomplete
|
36
36
|
# def token
|
37
|
-
#
|
37
|
+
# categories = Category.where("categories.name like ?", "%#{params[:q]}%")
|
38
|
+
#
|
38
39
|
# respond_to do |format|
|
39
|
-
# format.json { render :json =>
|
40
|
+
# format.json { render :json => categories.map(&:to_token) }
|
40
41
|
# end
|
41
42
|
# end
|
42
43
|
#
|
@@ -92,20 +93,16 @@ module TokenField
|
|
92
93
|
# end
|
93
94
|
def token_field(attribute_name, options = {})
|
94
95
|
association_type = @object.send(attribute_name).respond_to?(:each) ? :many : :one
|
95
|
-
model_name = (
|
96
|
+
model_name = options.fetch(:model) { attribute_name.to_s.gsub(/_ids?/, "") }.to_s
|
96
97
|
association = attribute_name.to_s.gsub(/_ids?/, "").to_sym
|
97
|
-
|
98
|
-
token_url = options[:token_url]
|
98
|
+
token_url = options.fetch(:token_url) { "/#{model_name.pluralize}/token.json" }
|
99
99
|
token_url_is_function = options.fetch(:token_url_is_function) { false }
|
100
100
|
append_to_id = options[:append_to_id]
|
101
|
+
token_method = options.fetch(:token_method) { :to_token }
|
101
102
|
|
102
103
|
token_limit = nil
|
103
104
|
token_limit = 1 if association_type == :one
|
104
105
|
|
105
|
-
if token_url.nil?
|
106
|
-
token_url = "/#{model_name.pluralize}/token.json"
|
107
|
-
end
|
108
|
-
|
109
106
|
id = @object.send(:id)
|
110
107
|
|
111
108
|
html_id = "#{@object_name}_#{attribute_name.to_s}"
|
@@ -116,16 +113,17 @@ module TokenField
|
|
116
113
|
end
|
117
114
|
html_id = html_id.parameterize.underscore
|
118
115
|
|
119
|
-
|
120
|
-
|
121
|
-
if association_type == :one && @object.
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
data_pre = model.token_json(@object.send(association.to_s.pluralize)).to_json()
|
126
|
-
value = @object.send(attribute_name).join(",")
|
116
|
+
results = []
|
117
|
+
|
118
|
+
if association_type == :one && @object.public_send(association)
|
119
|
+
results << @object.public_send(association)
|
120
|
+
elsif association_type == :many && @object.public_send(association.to_s.pluralize).count > 0
|
121
|
+
@object.public_send(association.to_s.pluralize).each { |record| results << record }
|
127
122
|
end
|
128
123
|
|
124
|
+
data_pre = results.map{ |result| result.public_send(token_method) }
|
125
|
+
value = data_pre.map{ |row| row[:id] }.join(',')
|
126
|
+
|
129
127
|
on_add = options[:on_add] ? "#{options[:on_add]}" : "false"
|
130
128
|
on_delete = options[:on_delete] ? "#{options[:on_delete]}" : "false"
|
131
129
|
|
@@ -149,7 +147,7 @@ module TokenField
|
|
149
147
|
});
|
150
148
|
"
|
151
149
|
script = content_tag(:script, js_content.html_safe, :type => Mime::JS)
|
152
|
-
text_field("#{attribute_name}", "data-pre" => data_pre, :value => value, :id => html_id) + script
|
150
|
+
text_field("#{attribute_name}", "data-pre" => data_pre.to_json, :value => value, :id => html_id) + script
|
153
151
|
end
|
154
152
|
end
|
155
153
|
end
|