Solved

ruby rails: uploaded file id

Posted on 2008-10-25
2
494 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now