Guest User

Untitled

a guest
Dec 11th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. ## Edit project form
  2.  
  3.  
  4. = form_for @project, :html => { :multipart => true } do |f|
  5. = f.error_messages
  6. %p
  7. = f.label :thumbnail_image
  8. = f.file_field :thumbnail_image
  9. %br
  10. = image_tag @project.thumbnail_image.url(:preview)
  11. %p
  12. = f.label :main_image
  13. = f.file_field :main_image
  14. %br
  15. = image_tag @project.main_image.url(:preview)
  16. %p
  17. = f.label :additional_images
  18. %br
  19. = f.fields_for :additional_images do |image|
  20. - if image.object.new_record?
  21. = image.file_field :additional_image
  22. %br
  23. = f.fields_for :additional_images do |image|
  24. - unless image.object.new_record?
  25. = link_to image_tag(image.object.additional_image.url(:thumb)), image.object.additional_image.url(:original)
  26. = image.label "Delete?"
  27. = image.check_box :_destroy
  28. %p
  29. = f.label :title
  30. = f.text_field :title
  31. %p
  32. = f.label :summary
  33. = f.text_field :summary
  34. %p
  35. = f.label :link
  36. = f.text_field :link
  37. %p
  38. = f.label :in_selected_projects?
  39. = f.check_box :in_selected_projects_list
  40. %p
  41. = f.label :category
  42. = f.select :category_list, options_for_select(['web', 'print', 'brand'])
  43. %p
  44. Comma separated tag list ...
  45. %br
  46. = f.label :tags
  47. = f.text_field :tag_list
  48. %h1
  49. Make Featured
  50. %p
  51. = label_tag :make_featured_project
  52. = check_box_tag :make_featured
  53. %p
  54. = label_tag :left
  55. = radio_button_tag "position", :left
  56. = label_tag :right
  57. = radio_button_tag "position", :right
  58. %p
  59. = f.label :featured_project_title
  60. = f.text_field :featured_project_title
  61. %p
  62. = f.label :featured_project_summary
  63. = f.text_field :featured_project_summary
  64. %p
  65. = f.submit
  66.  
  67.  
  68. ## project controller update method
  69.  
  70.  
  71. def update
  72. @project = Project.find(params[:id])
  73. if @project.update_attributes(params[:project])
  74. if params[:make_featured]
  75. raise @project.inspect
  76. config = ApplicationConfigs.find(1)
  77. config.front_page_featured_project_a = @project[:id]
  78. config.save
  79. end
  80. redirect_to edit_project_path(@project), :notice => "Successfully updated project."
  81. else
  82. render :action => 'edit'
  83. end
  84. end
Add Comment
Please, Sign In to add comment