Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ruby rails: uploaded file id

Posted on 2008-10-25
2
Medium Priority
?
505 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

916 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