Guest User

Untitled

a guest
Sep 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.94 KB | None | 0 0
  1.   def update
  2.     @post = Post.find(params[:id])
  3.     @categories = Category.all
  4.     @post.update_attributes(params[:post])
  5.     respond_with(@post)
  6.   end
  7.  
  8. ---------------------------------
  9.  
  10. = form_for(@post) do |f|
  11.  - if @post.errors.any?
  12.     div#error_explanation
  13.      h2
  14.       = pluralize(@post.errors.count, "error")
  15.       | prohibited this post from being saved:
  16.      ul
  17.       - @post.errors.full_messages.each do |msg|
  18.        li = msg
  19.  div.field
  20.   = f.label 'Заголовок:'
  21.   br
  22.   = f.text_field :title
  23.  div.field
  24.   = f.label 'Категории:'
  25.   br
  26.   = f.select(:category_ids, options_from_collection_for_select(@categories = Category.all, :id, :title, :selected => @post.category_ids), {}, {:multiple => true, :size => 7})
  27.  div.field
  28.   = f.label 'Текст:'
  29.   br
  30.   = f.text_area :content
  31.  div.field
  32.   = f.label :tags
  33.   br
  34.   = f.text_field :tag_list
  35.  div.actions
  36.   = f.submit 'Опубликовать'
Add Comment
Please, Sign In to add comment