我在rail_的form_for中有一个select选项。在安装实现之前,它一直在工作,但是在安装之后,它不再起作用。请在下面查看我的代码:
游戏模型
class Game < ActiveRecord::Base
GENRES = ['Action', 'Adventure', 'RPG', 'Simulation', 'Strategy', 'Sports', 'Others']
PLATFORMS = ['3DS', 'WII U', 'NX', 'PC', 'Playstation', 'XBOX', 'PS Vita', 'Mobile', 'Others']
end
new.html.erb
<h1> Add Game </h1>
<%= form_for :game, url: games_path do |f| %>
Title: <%= f.text_field :title %> <br />
Genre: <%= f.collection_select :genre, Game::GENRES, :to_s, :to_s, :include_blank => true %> <br />
Platform: <%= f.collection_select :platform, Game::PLATFORMS, :to_s, :to_s, :include_blank => true %> <br />
Release Date: <%= f.date_field :release_date %> <br />
Progress: <%= f.number_field :progress %> <br />
Rating: <%= f.number_field :rating %> <br />
<%= f.submit 'Add Game', class: 'add_game_button' %>
<%end%>
MaterializeCSS使用select
元素的自定义实现,您必须使用jQuery手动对其进行初始化:
$(document).ready(function() {
$('select').material_select();
});
有关更多详细信息,请查看MaterializeCSS docs。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句