Hi,
Can anyone tell me how I can pull a full url from an object I just
saved?
I need to send the saved object''s id to my thanks_url so I can build
another object in the thanks_url view.
if @video.save
flash[:notice] = ""
redirect_to thanks_url
else
....
end
Thanks!
-Mario
##FULL CODE
def new_video
@band = Band.find_by_id(params[:band_id])
return unless @band
# fix swfupload ampersand issue
params[:video_data] ||= params[''amp;video_data'']
# load data from form through swfupload
if params[:video_data]
params[:video] ||= Marshal.load(params[:video_data]) #rescue {}
# move swf''s data to the proper key
params[:video][:filename] = params[:Filedata]
end
@video = Video.new(params[:video])
@video.slug = URI.escape(@video.name)
@video.user_id = current_user.id
@video.band = @band
return unless request.post?
unless params[:Filename]
if @video.valid?
@temp = params[:video]
@upload = true
@old_params = {
:video_data => Marshal.dump(params[:video])
}
end
return
end
# Note: swfupload only cares about status code of the response, it
does
# not follow redirections, you will have use it''s callbacks.
if @video.save
flash[:notice] = ""
redirect_to thanks_url
else
raise @video.errors.inspect
render and return false
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I realized I could just do this, @video.save @video.id My problem was that becuase of a data error, the video wasn''t saving in the first place. Thanks, -Mario -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10/25/07, Mario Flores <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I realized I could just do this, > > > > @video.save > @video.id > > My problem was that becuase of a data error, the video wasn''t saving in > the first place.You might want to consider using save! instead of save. On a validation error save will return false, while save! will raise an exception. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---