S
S
Sergei Safronov2014-04-19 00:28:59
css
Sergei Safronov, 2014-04-19 00:28:59

How to add CSS style to Ruby code?

Hello, I'm new to RoR, writing a small project for myself. When I finished writing the functional, the question arose - how to style it all. I chose Bootstrap. Now the question is let's say there is a form <%= f.text_area :body %>
How to apply form style from Bootstrap to this code?<textarea rows=""></textarea>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Arkady Butermanov, 2014-04-19
@zirexx

I would advise you to use the gem https://github.com/plataformatec/simple_form
1. Add the gem.
2. rails generate simple_form:install --bootstrap
3.

<%= simple_form_for @зщые do |f| %>
  <%= f.input :body, as: :text %>
<% end %>

Everything else SimpleForm will do for you: add the necessary classes to the form and inputs, wrap the inputs in the necessary containers, etc.

A
anathem, 2014-04-19
@anathem

<%= form_for (@post), html: { class: 'form-horizontal' } do |f| %>
    <div class="form-group">
        <%= f.label :body, "Контент" %>
        <%= f.text_field :body, class: 'form-control' %>
    </div>
<% end %>

For example.

D
Dmitry Snegirev, 2014-04-26
@Rikkit

You can also see the bootstrap_form gem https://github.com/bootstrap-ruby/rails-bootstrap-forms

<%= bootstrap_form_for(@user) do |f| %>
  <%= f.email_field :email %>
  <%= f.password_field :password %>
  <%= f.check_box :remember_me %>
  <%= f.submit %>
<% end %>

In my opinion, most compatible with bootstrap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question