我創建了學習其中有3款小Rails應用程序:軌創建自定義操作
class Resource < ActiveRecord::Base
belongs_to :task
belongs_to :user
end
class User < ActiveRecord::Base
has_many :resources
has_many :tasks, :through=>:recources
end
class Task < ActiveRecord::Base
has_many :resources, :dependent => :destroy
has_many :comments, :dependent => :destroy
has_many :users, :through=>:resources
accepts_nested_attributes_for :resources,:comments
end
一切正常 - 上市,創造等,但我想打哪個用戶上傳文本的示意圖包含任務的文件(如何讀取文本文件並不重要),因此我讀取文件並獲取任務。我創建了名稱上傳控制器:
class UploadController < ApplicationController
def index
end
def upload
flash[:notice]="Upload completed"
end
end
和索引視圖這樣的:
<% if flash[:notice] %>
<p><%= flash[:notice] %></p>
<% end %>
<div class="upload">
<p>Select a project file</p>
<%= form_tag :controller=>:upload,:action => :upload,:method => :put do %>
<%= file_field 'Project File',:file %>
<%= submit_tag "Upload" %>
<% end %>
</div>
當我按下上傳按鈕它給了我「缺少模板上傳/ uploa ......」
我該如何做到這一點,給我建議plz。
感謝
嗨維森特做什麼,感謝的答覆,這是非常有益的。 – lote