diff --git a/app/models/asset.rb b/app/models/asset.rb index 05ae63e7..09d6dbd4 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -9,6 +9,11 @@ class Asset has_grid_attachment :data, :required => true before_validation :setup_filename + after_save :save_static_file + + def url + "/assets/#{self.filename}" + end protected @@ -18,4 +23,10 @@ class Asset end end + def save_static_file + f = File.new("#{RAILS_ROOT}/public/assets/#{self.filename}", "wb") + f.write(self.data.file.read) + f.close + end + end \ No newline at end of file diff --git a/app/views/admin/assets/index.html.erb b/app/views/admin/assets/index.html.erb index abf9d16a..be6a23ea 100644 --- a/app/views/admin/assets/index.html.erb +++ b/app/views/admin/assets/index.html.erb @@ -13,7 +13,9 @@ <% @assets.each do |asset| %>