2016-07-03 1 views
0

私はform_for in railsで選択オプションを持っています。マテリアライズをインストールする前に動作していましたが、インストールした後はもう動作しません。以下の私のコードを参照してください。MaterializeCSSを使用するRailsで選択オプションが機能しない

ゲームのモデルを

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%> 

答えて

1

MaterializeCSSはjQueryのを使用して、手動で初期化する必要があること、select要素のカスタム実装を使用しています。

$(document).ready(function() { 
    $('select').material_select(); 
}); 

詳細については、をチェックしてください。

関連する問題