Mohamed El Mahallawy
Mohamed El Mahallawy

Reputation: 921

Bootstrap 3 gem on rails 3.2 form distorted

Using this gem: https://github.com/anjlab/bootstrap-rails

For some reason the forms are not working properly for me. There is not curves when the input is being used.

enter image description here

And I cannot add classes to it like 'form-inline' Not sure what the problem is. Anyone else facing this/have a solution?

After digging further, and deciding to trial and error, I got it working but have to manually input the classes for each form.

<%= text_field_tag :twitter_contact, nil, class: 'form-control'%>

Now i have this: enter image description here

Why is the gem not working automatically to do that itself? Am I missing something?

Upvotes: 0

Views: 342

Answers (1)

Farley Knight
Farley Knight

Reputation: 1793

You can write you own helper methods that include this for you. For example

def my_text_field_tag(name, value)
  text_field_tag(name, value, class: 'form-control')
end

in your ApplicationHelper would give you something closer to what you're looking for.

The fact is that Ruby gem authors have to be careful injecting too much auto-magic into their code, as it actually conflicts with other Ruby gems. To a certain extent, you have to learn how Ruby works in order to get the full magic that you're looking for.

Upvotes: 1

Related Questions