Я новичок в разработке rails и пытаюсь заставить работать гем auto_html, но в поле body_html БД ничего не сохраняется.Я также не получаю никаких ошибок, поэтому кажется, что гем просто не вызывают.
Я включил гем в свой гемфайл и запустил установку пакета.Я что-то не правильно делаю?Я думал, что мне не нужно нигде вызывать метод auto_html, потому что в модели есть auto_html_for.
Я на Rails 3.2.1 и ruby 1.9.3p125 и auto_html 1.5.1
Модель:
class Video < ActiveRecord::Base
belongs_to :campaign
auto_html_for :body do
html_escape
image
youtube(:width => 400, :height => 250)
link :target => "_blank", :rel => "nofollow"
simple_format
end
end
Контроллер:
class VideosController < ApplicationController
def new
@video = Video.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @video }
end
end
def create
@video = Video.new(params[:video])
respond_to do |format|
if @video.save
format.html { redirect_to videos_path(:campaign => "#{@video.campaign_id}"), notice: 'Video was successfully created.' }
format.json { render json: @video, status: :created, location: @video }
else
format.html { render action: "new" }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end
Просмотр:
= simple_form_for @video do |f|
.field
= f.hidden_field :campaign_id, :value => "#{params[:campaign]}"
= f.text_area :body
.actions
= f.submit 'Save'
РЕДАКТИРОВАНИЕ: определение таблицы видео из schema.rb
create_table "videos", :force => true do |t|
t.text "body"
t.text "body_html"
t.integer "campaign_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end