--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3bac38e2-4346-4f15-b04e-0fa4ef945979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello Alfredo,
The problem here is the script tag as you are using it without any attribute as type/language.
Please refer https://developer.mozilla.org/en/docs/Web/HTML/Element/script for more details. The script tag if not given type will be treated as JavaScript tag.
Hence in your case browser is considering that this script tag contains JavaScript code and giving such errors.
For using coffeescript in script tags you can refer http://forgivingworm.wordpress.com/2010/09/27/running-coffeescript-in-browser/
I'm having a new issue related with this. I have been searching the reason of it but I cannot fix it.
I have this button:
<%= button_to 'Go to Gallery', loading_gallery_path,
remote: true %>
And this is the controller function:
def gallery
respond_to do |format|
format.html { redirect_to user_path(current_user.id) }
format.js
format.json { render action: 'show', status: :created, location: @comment }
end
end
This is the code of the 'gallery.js.erb' => $('#user-comments').html("<%= escape_javascript render(:partial => 'change.html.erb') %>");
And this is the template that the browser is not rendering: <% print 'CHANGING' %><p>Testing<p>
In the log of the application I can see that this template is being opened by the browser but never rendered in the screen. Below is the log:
Started POST "/users/1/gallery" for 127.0.0.1 at 2014-05-06 13:15:39 +0200
Processing by UsersController#gallery as JS
Parameters: {"authenticity_token"=>"MQ2R+gPxDpCjEVzNrTheQD40nDUblLnlONls5ahub8E=", "id"=>"1"}
CHANGING Rendered users/_change.html.erb (0.1ms)
Rendered users/gallery.js.erb within layouts/user-layout.html.erb (2.6ms)
Completed 200 OK in 87ms (Views: 85.3ms | ActiveRecord: 0.0ms)
Hello Alfredo,
Your button_to tag is creating the form on the page which is sending post type request. When you are retrieving in controller action the request type should be 'get'.
Please use link_to helper as follows:
= button_tag(link_to('Go to Gallery', loading_gallery_path, remote: true))
This will create a button tag with an anchor tag init.
When clicked on this link an remote request with will be sent controller action and your response js.erb will be rendered properly.
There may be an possibility that you rendered code is having any error while execution. Please debug the response in that case.
--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/gju5JdKqU_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/770b752c-2c6a-4d20-b50c-f7b420417601%40googlegroups.com.