1

Here's the relevant controller code:

if @song.update_attributes(params[:song]) respond_to do |format| format.js { render :action => 'success' } end else 

Here's what's in success.js.erb:

$("#song_updated_at").val( "<%= escape_javascript @song.updated_at %>" ) 

Here's the error I get:

ActionView::TemplateError ($_ value need to be String (nil given)) on line #1 of app/views/songs/success.js.erb: 1: $("#song_updated_at").val( "<%= escape_javascript @song.updated_at %>" ) app/views/songs/success.js.erb:1 app/controllers/songs_controller.rb:52:in `update' app/controllers/songs_controller.rb:50:in `update' 

Thoughts?

1 Answer 1

2

You need to to_s your updated_at, because escape_javascript expects a String. updated_at returns a ActiveSupport::TimeWithZone.

Hope this helps.

Sign up to request clarification or add additional context in comments.

2 Comments

ARGGHHHHH! escape_javascript should take care of this automatically!
I agree, I don't understand why it doesn't.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.