Solved

ruby rails: uploaded file id

Posted on 2008-10-25
2
499 Views
Last Modified: 2013-11-13
I am uploading a file as follows (snippet attached).  I would like to know whats the id(database column) of this uploaded file. Is there any way I can get it?

Thanks,
GT.
def save_attachment
    @program = @object
    @attachment = Attachment.new
	if request.post? && params[:attachment]
      @attachment = @program.attachments.build(params[:attachment])
      @attachment.name = @attachment.filename if @attachment.name.blank?
      result = false
      logger.silence do
        result = @attachment.save
      end
      
      if result
        update_event(@program.event)
	    flash[:notice] = "Upload successful"
        redirect_to :controller => :main, :action => :show_event, :id => @program.event
      end
	end
  end

Open in new window

0
Comment
Question by:gt9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 22804593
if you want the id of the upload then it would be  @program.event_id  looking at your code.
0
 

Accepted Solution

by:
gt9 earned 0 total points
ID: 22805377
Solved:
@attachment.id , after the result of upload is true..
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ruby on Rails Installation Error 5 320
Rails installation ? 6 845
Ruby problem with blocks 5 337
return captures in array 5 261
I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question