-
Notifications
You must be signed in to change notification settings - Fork 251
use RailsAdmin
SammyLin edited this page Sep 18, 2012
·
1 revision
Because use redactorjs in RailsAdmin need overwrite the gem code, so i use partials.
$ touch app/views/rails_admin/main/_form_redactor.html.erb
<%= form.send :text_area, field.method_name, :class => 'redactor' %>
<link rel="stylesheet" type="text/css" href="/assets/redactor-rails/css/redactor.css" />
<script media="all" src="/assets/redactor-rails/redactor.min.js?body=1" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
var params;
if (csrf_param !== undefined && csrf_token !== undefined) {
params = csrf_param + "=" + encodeURIComponent(csrf_token);
}
$('.redactor').redactor(
{ "imageUpload":"/redactor_rails/pictures?" + params,
"imageGetJson":"/redactor_rails/pictures",
"autoresize": false,
"path":"/assets/redactor-rails",
"css":"style.css"}
);
});
</script>
config.model Page do
edit do
field :title
field :content, :text do
partial 'form_redactor'
end
end
end