Solved

ruby rails: uploaded file id

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

20 Experts available now in Live!

Get 1:1 Help Now