Skip to content

Instantly share code, notes, and snippets.

@dallarosa
Created January 21, 2011 09:14
Show Gist options
  • Save dallarosa/789452 to your computer and use it in GitHub Desktop.
Save dallarosa/789452 to your computer and use it in GitHub Desktop.
class Task < ActiveRecord::Base
attr_accessor :infile_file_name
attr_accessor :infile_content_type
attr_accessor :infile_file_size
attr_accessor :infile_updated_at
validates_presence_of :name
has_attached_file :infile, :path => ":rails_root/public/system/:user_id/:id/inputs/:filename"
belongs_to :user
end
#just a part of the file
def create
@user = User.find(params[:user_id])
@task = Task.new(params[:task])
@task.user_id = @user.id
@task.status = 0
if(@task.save)
flash[:notice] = "Task " << @task.name << " has been successfuly registered"
redirect_to :action => "index"
else
flash[:notice] = @task.errors
redirect_to :action => "new"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment