Solved

ruby rails: uploaded file id

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Timed out after 5000ms (Selenium::CommandError) 2 490
=> syntax in ruby 1 346
Ruby 2-D array 1 174
Javascript: handler for multi-select dropdown 8 106
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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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