You are here: Forums Ask a Rails expert how to show the params value i...
Posted in Forums : Ask a Rails expert
Authority 12
Posting Rating 3
Sign in to rate this post
|
hi to everyone how to show the params value in page.alert page.alert(‘Your image has been uploaded sucessfully’ +‘params:image.original_filename’) |
Authority 62
Posting Rating 7
Sign in to rate this post
|
Minor tweak, but that should be: page.alert(‘Your image has been uploaded sucessfully ’ + params[:image].original_filename) |
Authority 62
Posting Rating 100
Sign in to rate this post
|
I don’t agree with Josh. params[:image] is a string so you can’t just call original_filename on it. I guess you’re using a plugin like attachment_fu or Paperclip for your uploads. Both store the original filename in the database. I think it’s called @your_attachment_model.filename in attachment_fu and @model_with_attachment.xxx_file_name in Paperclip (where ‘xxx’ is the value you pass to has_attached_file, e.g. has_attached_file :logo gives you @model_with_attachment.logo_file_name). I guess you’re using page.alert in an AJAX response so you should have your model available anyways. Maybe the following will do the trick:
page.alert("Your image #{@your_model.filename} has been uploaded successfully!") # attachment_fu
page.alert("Your image #{@your_model.xxx_file_name} has been uploaded successfully!") # Paperclip
|
Ask a Rails expert : How to parse <pubdate> in RSS
Ask a Rails expert : Couldn't find Product without an ID
Ask a Rails expert : HTML to XML ---> get title & description
Ask a Rails expert : Accessing controller actions from scripted page?
Ask a Rails expert : seledted option for select_tag
Ask a Rails expert : Merging fields from two tables into one, including duplicates
Ask a Rails expert : saving has_many :through
Ask a Rails expert : Use Rails to develop sites for both Designer and Programmer
Ask a Rails expert : Rails+RS232
Ask a Rails expert : Is this a good way to add Admin section