Search code examples
ruby-on-railsbootstrap-4simple-form

Simple form styling does not work


I have started a new app with simple_form and my forms don't have styles.

Gemfile:

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

My app/assets/stylesheets/application.rb:

@import "bootstrap";

Form code:

.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 'Войти'

And it generates

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

Which looks like this:

enter image description here

What I can see, it at least doesn't generate <div class='form-group'> etc around each input. I've run rails generate simple_form:install --bootstrap. And can provide all information needed.

What can be the point of it?


Solution

  • Simple Form use this syntax :

    f.input :username
    

    https://github.com/plataformatec/simple_form