Reputation: 1695
So this is my controller function.
def fb_close
current_user.update_user_points(SHARE_POINT_ONE, message, current_user.id, 0) if params[:post_id].present?
respond_to do |format|
format.js { render :js => "my_function();" }
end
end
and im trying to go back a js function called my_function inside script tag on the same page. I'm getting an error like ActionController::UnknownFormat
I want to know where i was wrong. Please correct me.
I have a file named fb_close.html.erb i can get the call to that file.. Is there any way i can link it with a js function
Upvotes: 1
Views: 3659
Reputation: 33542
You should be better putting the code of my_function
in a separate file of format js
and call it like format.js { render 'your_file_name' }
respond_to do |format|
format.js { render 'your_file_name' }
end
You have to create a file like fb_close.js.erb
and put the code of my_function
in it and call it like this
respond_to do |format|
format.js { render 'fb_close' }
end
Upvotes: 2