Reputation: 2681
I am trying to use jquery drag and drop uploader by following this example
https://github.com/jalagrange/bootstrap_uploader
My View:
<%= form_for @object_new, :html => { :multipart => true, :id => "fileupload" } do |f| %>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="span7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i>
<span>Add files...</span>
<%= f.file_field :path, :multiple => true %>
</span>
<button type="submit" class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
</div>
<div class="span5">
<!-- The global progress bar -->
<div class="progress progress-success progress-striped active fade">
<div class="bar" style="width:0%;"></div>
</div>
</div>
</div>
<!-- The loading indicator is shown during image processing -->
<div class="fileupload-loading"></div>
<br>
<!-- The table listing the files available for upload/download -->
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody>
</table>
<% end %>
Controller:
def upload
@object_new= Property::File.new
end
Model:
class Property::File < ActiveRecord::Base
attr_accessible :date, :description, :location, :name, :time ,:path
end
Schema:
create_table "property_files", :force => true do |t|
t.string "name"
t.string "description"
t.string "date"
t.datetime "time"
t.string "location"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "path"
end
routes.rb
root :to => "property#home"
get "property/home"
get "property/upload"
When I run my view I got this error:
NoMethodError in Property#upload
Showing C:/myproject/app/views/property/upload.html.erb where line #71 raised:
undefined method `property_files_path' for #<#<Class:0x563d3a8>:0x563b5a8>
Extracted source (around line #71):
68: </div><!--/span-->
69: <div class="span9">
70:
71: <%= form_for @object_new, :html => { :multipart => true, :id => "fileupload" } do |f| %>
72: <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
73: <div class="row fileupload-buttonbar">
74: <div class="span7">
Rails.root: C:/myproject
I don't understand where property_files_path
is being used in view.
Thanks for any help
Upvotes: 0
Views: 74
Reputation: 34072
It's being called by the form generator. For this to work you probably want to add:
resources :property_files
... to your routes.
If you do not want the form to default to resourceful routes, you can specify your own path for the upload action by passing the url
option to form_for
, for example:
<% form_for @object_new, {:url => "/property_files/upload", ... } %>
Upvotes: 1