Class: Property::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/ecrire/app/models/property/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#postObject

Returns the value of attribute post.



3
4
5
# File 'lib/ecrire/app/models/property/image.rb', line 3

def post
  @post
end

Instance Method Details

#create(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/ecrire/app/models/property/image.rb', line 9

def create(params)
  unless post.header.nil?
    post.header.destroy
  end
  img = post.images.build
  img.file = params[:admin_image][:file]
  img.save
  post.header = img
  post.save
end

#destroy(value) ⇒ Object

TODO:

  1. Remove id in post properties



22
23
24
25
26
# File 'lib/ecrire/app/models/property/image.rb', line 22

def destroy(value)
  return if post.header.nil?
  img = post.header
  img.destroy
end

#nameObject



5
6
7
# File 'lib/ecrire/app/models/property/image.rb', line 5

def name
  "image"
end