Summernote text Area for rails

in #ruby7 years ago (edited)

Summernote.png

Summer note a a text area widget which changes your boring text area field to a rich text editor field
which makes your application more user friendly..

I am showing how you can add to your rails app in this article.

add gem to Gemfile

gem 'summernote-rails', '~> 0.8.10.0'

then, update following files.

app/assets/javascripts/application.js
add following lines.

//= require summernote/summernote-bs4.min
//= require summernote-init

Screenshot from 2018-04-19 02-43-09.png

Now find this css file, and update it like so

app/assets/stylesheets/application.css.scss

@import "summernote-bs4";
@import "summernote-custom-theme.min";

Screenshot from 2018-04-19 02-44-40.png

Finally add this coffee script to your javascript directory

$(document).on 'turbolinks:load', ->
  $('[data-provider="summernote"]').each ->
    $(this).summernote
      height: 300

Screenshot from 2018-04-19 02-45-51.png

Fun part How to use it ?

In your form fields, just add data-provider to summernote
That's it, and it will change your regular boring text area field to what you have seen in above image.

 <div class="form-group">
     <%= f.label :vote_message %>
    ## Boring Text Area
    <%= f.text_area :vote_message , class: 'form-control'%>
    ## Awesome Text Area
    <%= f.text_area :vote_message , 'data-provider': :summernote, class: 'form-control'%>
   </div>
Sort:  

Thank you for this useful post

Wow! This is great content! You have received a free upvote from the Minnows Freedom Project for being a good Steemian and posting original content. To learn more about us or to support us, please visit @minnows-freedom. You can also find us on Discord. Stay cool, create good content and have a nice day!

Congratulations @bilal-haider! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of posts published

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!