定義済みのリストから複数の項目を選択する tokenInput jquery プラグインを使用しており、入力時にオートコンプリートを使用して各項目を検索しています。
プラグインは見栄えがよく、データは生成されていますが、トークンを選択してページを送信すると、トークンの値が保存されません。送信時にトークン値を保存するにはどうすればよいですか?
html.erb:
<%= form_for @idea, :html => { :multipart => true } do |f| %>
<div>
<input type="text" id="tokens" name="store_ids" />
</div>
<%= f.submit %>
<% end %>
脚本:
$(document).ready(function() {
var tokens = $('.stores').map(function(index, name) {
var name = $(name)
return {
name: $(name).attr('value')
}
})
$("#tokens").tokenInput(tokens);
});
Rails サーバーログ:
Started GET "/ideas/bpul_dishes" for 127.0.0.1 at 2013-10-11 14:03:13 -0400
Processing by IdeasController#show as HTML
Parameters: {"id"=>"bpul_dishes"}
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 6 ORDER BY
`users`.`id` ASC LIMIT 1
Idea Load (0.4ms) SELECT `ideas`.* FROM `ideas` WHERE `ideas`.`deleted` = 0 AND
`ideas`.`permalink` = 'bpul_dishes' ORDER BY `ideas`.sku ASC LIMIT 1
Role Load (0.5ms) SELECT DISTINCT `roles`.* FROM `roles` INNER JOIN `users_roles` ON
`roles`.`id` = `users_roles`.`role_id` WHERE `users_roles`.`user_id` = 6 ORDER BY name
asc, `roles`.name ASC
Rendered ideas/_ideas_nav.html.erb (3.2ms)
Store Load (0.6ms) SELECT DISTINCT `stores`.* FROM `stores` INNER JOIN `stores_ideas`
ON `stores`.`id` = `stores_ideas`.`store_id` WHERE `stores_ideas`.`idea_id` = 201 ORDER
BY name asc
Taxonomy Load (0.4ms) SELECT DISTINCT `taxonomies`.* FROM `taxonomies` INNER JOIN
`taxonomies_ideas` ON `taxonomies`.`id` = `taxonomies_ideas`.`taxonomy_id` WHERE
`taxonomies_ideas`.`idea_id` = 201 ORDER BY store_id
Imprintable Load (0.4ms) SELECT DISTINCT `imprintables`.* FROM `imprintables` INNER JOIN
`imprintables_ideas` ON `imprintables`.`id` = `imprintables_ideas`.`imprintable_id` WHERE
`imprintables_ideas`.`idea_id` = 201
(0.2ms) SELECT COUNT(*) FROM `artworks` WHERE `artworks`.`idea_id` = 201
Artwork Load (0.2ms) SELECT `artworks`.* FROM `artworks` WHERE `artworks`.`id` = 343
ORDER BY `artworks`.`id` ASC LIMIT 1
CACHE (0.0ms) SELECT COUNT(*) FROM `artworks` WHERE `artworks`.`idea_id` = 201
[["idea_id", 201]]
CACHE (0.0ms) SELECT COUNT(*) FROM `artworks` WHERE `artworks`.`idea_id` = 201
[["idea_id", 201]]
CACHE (0.0ms) SELECT COUNT(*) FROM `artworks` WHERE `artworks`.`idea_id` = 201
[["idea_id", 201]]
Color Load (0.8ms) SELECT DISTINCT `colors`.* FROM `colors` INNER JOIN `colors_ideas`
ON
`colors`.`id` = `colors_ideas`.`color_id` WHERE `colors_ideas`.`idea_id` = 201 ORDER BY
name
asc
Artwork Load (0.4ms) SELECT `artworks`.* FROM `artworks` WHERE `artworks`.`idea_id` =
201
ORDER BY dimensions ASC
(0.5ms) SELECT DISTINCT COUNT(DISTINCT `colors`.`id`) FROM `colors` INNER JOIN
`colors_ideas` ON `colors`.`id` = `colors_ideas`.`color_id` WHERE
`colors_ideas`.`idea_id` =
201
CACHE (0.0ms) SELECT DISTINCT COUNT(DISTINCT `colors`.`id`) FROM `colors` INNER JOIN
`colors_ideas` ON `colors`.`id` = `colors_ideas`.`color_id` WHERE
`colors_ideas`.`idea_id` =
201 [["idea_id", 201]]
Rendered ideas/show.html.erb within layouts/application (23.6ms)
Rendered shared/_header.html.erb (0.4ms)
Rendered shared/_navigation.html.erb (0.5ms)
Rendered shared/_main.html.erb (0.0ms)
Completed 200 OK in 74ms (Views: 64.7ms | ActiveRecord: 7.0ms)