Add image to budget investments.
This commit is contained in:
committed by
Senén Rodero Rodríguez
parent
f2e44f0730
commit
7b88e63136
@@ -106,7 +106,7 @@ module Budgets
|
||||
|
||||
def investment_params
|
||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list,
|
||||
:organization_name, :location, :terms_of_service,
|
||||
:organization_name, :location, :terms_of_service, :image,
|
||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
|
||||
end
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ class Budget
|
||||
has_many :comments, as: :commentable
|
||||
has_many :milestones
|
||||
|
||||
has_attached_file :image, styles: { large: "600x600>" ,medium: "300x300>", thumb: "100x100>" }
|
||||
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
|
||||
|
||||
validates :title, presence: true
|
||||
validates :author, presence: true
|
||||
validates :description, presence: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= form_for(@investment, url: form_url, method: :post) do |f| %>
|
||||
<%= form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %>
|
||||
<%= render 'shared/errors', resource: @investment %>
|
||||
|
||||
<div class="row">
|
||||
@@ -53,6 +53,9 @@
|
||||
data: {js_url: suggest_tags_path} %>
|
||||
</div>
|
||||
|
||||
<div class="budget_investment_image">
|
||||
<%= f.file_field :image %>
|
||||
</div>
|
||||
|
||||
<% unless current_user.manager? %>
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
|
||||
<% unless investment.unfeasible? %>
|
||||
|
||||
<% if investment.image.exists? %>
|
||||
<div class="small-12 medium-3 column">
|
||||
<%= image_tag investment.image.url(:medium) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if investment.should_show_votes? %>
|
||||
<div id="<%= dom_id(investment) %>_votes"
|
||||
class="small-12 medium-3 column text-center">
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if investment.image.exists? %>
|
||||
<%= image_tag investment.image.url(:large) %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'shared/tags', taggable: investment %>
|
||||
|
||||
<%= safe_html_with_links investment.description.html_safe %>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class AddAttachmentImageToBudgetInvestments < ActiveRecord::Migration
|
||||
def self.up
|
||||
change_table :budget_investments do |t|
|
||||
t.attachment :image
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_attachment :budget_investments, :image
|
||||
end
|
||||
end
|
||||
@@ -161,6 +161,10 @@ ActiveRecord::Schema.define(version: 20170918231410) do
|
||||
t.boolean "winner", default: false
|
||||
t.boolean "incompatible", default: false
|
||||
t.integer "community_id"
|
||||
t.string "image_file_name"
|
||||
t.string "image_content_type"
|
||||
t.integer "image_file_size"
|
||||
t.datetime "image_updated_at"
|
||||
end
|
||||
|
||||
add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree
|
||||
|
||||
Reference in New Issue
Block a user