i created a small rails application for learning which has 3 models :
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
everything is ok – listing,creating etc. But i wanna make a view which user upload a text file that contains tasks (it is not important how i can read text file) so i read the file and fetch the tasks. I created a controller which name is upload :
class UploadController < ApplicationController
def index
end
def upload
flash[:notice]="Upload completed"
end
end
and index view like this :
<% 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>
when i press upload button it gives me “Missing template upload/uploa….”
How can i accomplish this action, give me advice plz.
Thanks
Every action tries to render a template with the same name as itself if you don’t specifically tell it what to
renderorredirect_to. So what you can do is this:That should do what you want.
Also, the documentation is decent with regard to what you can do with render