2013-08-02 36 views
2

我遇到了wysihtml5编辑器(用于引导程序)。它只需要三条线并消除其他线。当我在编辑器中输入10行时。它只需要三条线。这样才能保存三条线。wysihtml5在导轨中无法正常工作

鉴于(_form.html.erb):

<%= simple_form_for @announcement, :html => { :class => 'form-horizontal' } do |f| %> 
    <%= f.input :name %><br/> 
    <%= f.input :description, as: 'text', :input_html =>{:rows => '25', :cols => '25', :class => 'input wysihtml5' } %> 
    <div class="input string optional"><label class="string optional control-label" for="school_school_name">Upload Logo</label> 
    <%= f.fields_for :pictures do |i| %> 
     <%= i.file_field :avatar %> 
    <% end %></div><br/> 
    <div class="form-actions"> 
    <%= f.button :submit, :class => 'btn-primary' %> 
    <%= link_to t('.cancel', :default => t("helpers.links.cancel")), 
       announcements_path, :class => 'btn' %> 
    </div> 
<% end %> 

模型:

include ActionView::Helpers::SanitizeHelper 
class Announcement < ActiveRecord::Base 
    attr_accessible :description, :name, :pictures_attributes 


    #association 
    has_many :pictures, :as => :imageable 
    accepts_nested_attributes_for :pictures, allow_destroy: :true 


    #before_save :strip_html 

end 

控制器:

class AnnouncementsController < ApplicationController 
    # GET /announcements 
    # GET /announcements.json 
    def index 
    @announcements = Announcement.all 

    respond_to do |format| 
     format.html # index.html.erb 
     format.json { render json: @announcements } 
    end 
    end 

    # GET /announcements/1 
    # GET /announcements/1.json 
    def show 
    @announcement = Announcement.find(params[:id]) 

    respond_to do |format| 
     format.html # show.html.erb 
     format.json { render json: @announcement } 
    end 
    end 

    # GET /announcements/new 
    # GET /announcements/new.json 
    def new 
    @announcement = Announcement.new 
    @announcement.pictures.build 

    respond_to do |format| 
     format.html # new.html.erb 
     format.json { render json: @announcement } 
    end 
    end 

    # GET /announcements/1/edit 
    def edit 
    @announcement = Announcement.find(params[:id]) 
    end 

    # POST /announcements 
    # POST /announcements.json 
    def create 
    @announcement = Announcement.new(params[:announcement]) 

    respond_to do |format| 
     if @announcement.save 
     format.html { redirect_to @announcement, notice: 'Announcement was successfully created.' } 
     format.json { render json: @announcement, status: :created, location: @announcement } 
     else 
     format.html { render action: "new" } 
     format.json { render json: @announcement.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # PUT /announcements/1 
    # PUT /announcements/1.json 
    def update 
    @announcement = Announcement.find(params[:id]) 

    respond_to do |format| 
     if @announcement.update_attributes(params[:announcement]) 
     format.html { redirect_to @announcement, notice: 'Announcement was successfully updated.' } 
     format.json { head :no_content } 
     else 
     format.html { render action: "edit" } 
     format.json { render json: @announcement.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # DELETE /announcements/1 
    # DELETE /announcements/1.json 
    def destroy 
    @announcement = Announcement.find(params[:id]) 
    @announcement.destroy 

    respond_to do |format| 
     format.html { redirect_to announcements_url } 
     format.json { head :no_content } 
    end 
    end 
end 

JS脚本运行wysihtml5

$(document).ready(function(){ 
    $(".wysihtml5").wysihtml5();  
}) 
+0

尝试查看通过Web服务器传递的param [:description]以检查值是否正确。 – Nich

回答

0

我的猜测是因为你的属性设置为数据库中的错误类型。你可能把它作为字符串而不是文本,所以它会自动截断它。