I create a post and inside the post I want to use pictures. I use Paperclip to upload images.

There is a form new.haml

 .container %header %h1 Новая статья = simple_form_for @post do |f| %h5 Тема = f.input :theme, label: false %h5 Аннотация = f.input :annotate, label: false %h5 Основная картинка = f.file_field :main_image %h5 Текст статьи = f.input :text, label: false %h5 Изображения .illustrations = f.simple_fields_for :illustrations do |ill| .entry = ill.file_field :image %button.btn.btn-add{:type => "button", :id => "add_image"} 'Добавить еще картинку' = f.submit 'Создать' 

From it I can add a lot of pictures to the post.

The question is: how to register a link to a picture in the text of the post. To markdown dismantled it.

PS I saw an article on this topic, but they refer to id pictures in the table, but I don’t have one yet. How to be I do not know.

Thanks in advance.

  • Do you understand correctly that you want to insert images into an arbitrary point of the markdown text? - cheops
  • Yes, you understand correctly. - Vasily
  • Then I would not cling the images to the post model, but I would store them in a separate table - this would allow saving the image first, and then using the link. If it is important for you to take into account the links of the images with the post, it is better to hang up to save the post kollback - parse the text of the post and establish links after saving the post. - cheops
  • Thanks, I will try to implement on a callback! - Vasily

0