LoginSignup
0
0

More than 5 years have passed since last update.

在 Rails 安裝 simple_form 、並搭配 Bootstrap 樣式

Posted at

simple_form 是讓 Rails application 製作表單更加容易的套件。這篇會說明怎麼安裝進 Rails 的專案中,並建立 Bootstrap 樣式的 simple_form 元件。

前置作業

在需要使用 Bootstrap 樣式的元件的時,也必須要確認有將 Bootstrap 的資源放入專案中。安裝的方式可以參考 "在 Rails 專案加入 Bootstrap 套件" (同步發布:熊屋) 這篇文章。

版本

  • rails 4.2
  • simple_form 3.1.1

加入 Gemfile

要使用這個 gem, 當然要先加入 Gemfile 裡面,請確保在不同的部署, development/production/... ,都可以使用到。

Gemfile
gem 'simple_form'

存擋後,執行

bundle install

完成安裝

產生 simple_form 的相關元件

如果沒有用任何的 UI framework ,可以在專案的根目錄下,直接執行以下指令產生必要的檔案:

rails g simple_form:install

如果你有用 Bootstrap

就執行以下指令

rails g simple_form:install --bootstrap

這樣就安裝完成了

重啟 Rails server

完成後,需要重啟 rails server

rails s

其他資源

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0