port5432
port5432

Reputation: 6371

Bootstrap markdown with Rails and Simple Form

I'm trying to add Bootstrap Markdown to a Rails app, using a gem. I am also trying to use simple_form to format the layout. https://github.com/dannytatom/rails-bootstrap-markdown

Bootstrap Markdown requires a data-provide attribute, as shown in the html code from the project's github site: http://toopay.github.io/bootstrap-markdown/

<textarea name="content" data-provide="markdown" rows="10"></textarea>

But when I try to do this in my simple_form, I get an error: wrong number of arguments (0 for 1..2)

<%= simple_form_for(@essay) do |f| %>
  <%= f.error_notification %>
    <div class="form-inputs">
      <%= f.input :class %>
      <%= f.input :title %>
      <%= f.input :essay, :input_html => {:rows => 5, :placeholder => "Enter some text.", :class => "span6", :data-provide => "markdown" }%>
      <%= f.input :status %>
    </div>

Upvotes: 0

Views: 1401

Answers (1)

Helios de Guerra
Helios de Guerra

Reputation: 3475

Ruby doesn't accept a '-' in a symbol... You need to provide your data-provide as a string... Everything else looks okay. e.g.

<%= f.input :essay, :input_html => {:rows => 5, :placeholder => "Enter some text.", :class => "span6", "data-provide" => "markdown" }%>

Or, optionally I think you could also use the Rails data hash like so:

<%= f.input :essay, :input_html => {:rows => 5, :placeholder => "Enter some text.", :class => "span6", :data => {:provide => "markdown"} }%>

The latter method might be better if you're providing a lot of data attributes, but for a single attr the first seems more readable.

Upvotes: 2

Related Questions