我用启动了一个新的应用程序
simple_form
我的表格没有样式。
GemFile(GEM文件):
source 'https://rubygems.org'
# BACK
gem 'rails', '4.2.7.1'
gem 'pg', '~> 0.15'
# FRONT
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'uglifier', '>= 1.3.0'
gem 'jbuilder', '~> 2.0'
gem 'simple_form'
gem 'slim'
gem 'bootstrap', '~> 4.1.1'
gem 'sprockets-rails', '>=2.3.2'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails', '~> 3.7'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'rubocop'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
我的
app/assets/stylesheets/application.rb
:
@import "bootstrap";
表单代码:
.row
.offset-md-3.col-md-6
= simple_form_for :user, url: sessions_path do |f|
= f.text_field :username
= f.password_field :password
= f.submit 'ÐойÑи'
它会产生
<form novalidate="novalidate" class="simple_form user" action="/sessions" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="â">
<input type="hidden" name="authenticity_token" value="...">
<input type="text" name="user[username]" id="user_username">
<input type="password" name="user[password]" id="user_password">
<input type="submit" name="commit" value="ÐойÑи">
</form>
看起来是这样的:
我能看到的是,它至少不会产生
<div class='form-group'>
每个输入的周围。
我已经跑了
rails generate simple_form:install --bootstrap
. 并能提供所需的所有信息。
有什么意义?