3
votes

I install gem 'redactor-rails', it's text editor. I want to use it with simple_form, but I have trouble.

If I use it with standart rails helper form_for:

 <%= form_for(@profile) do |f| %>  
   <%= f.text_area :aboutme, placeholder: "Content goes here...", :class => "redactor"%>
 <% end %>

It's all right. I can edit text with bold, italic and etc.

But when I try to use it with simple_form:

<%= simple_form_for(@profile) do |f| %>  
<%= render 'devise/shared/error_messages', object: f.object %>
<%= f.input :aboutme, input_html: { class: "redactor",  as: :text } %>
<%= text_area_tag :editor, "Ghbtd", :class => "redactor", :rows => 40, :cols => 120 %>
<%= f.submit "Сохранить", class: "btn  btn-primary" %>
<% end %>

I especially add text_area_tag from usual form, it's create two fields, one field(with text_area_tag) it's works good, but Redactors field created with simple_form become the simple field, I can't modify it's with Redactors, I can only input text, and it have width as other fields in form, but with text_area_tag it's have bigger width. as:text attribute should create field how text_area in simple_form, why it doesn't work?

1
Why you are using 'text_area_tag' ?sunil

1 Answers

1
votes

For people who still facing this kind of problem, for the above problem do it like this-

<%= simple_form_for(@profile) do |f| %>  
    <%= f.input :aboutme, label: 'Your label', :as => :text, :input_html => { :class => "redactor" } %>
    <%= f.submit "Сохранить", class: "btn  btn-primary" %>
<% end %>