So here is my point, i tried to follow some tutorial and read all of the references in the end from http://8raystech.com/2011/11/28/how-to-create-embeddable-widgets-with-rails
I spent almost 2 days searching for the little mistake I obviously made somewhere since I'm new to ruby on rails. I think it might be a route error since when I inspect elements via Chrome, i see the following error: EDIT:
"GET http://localhost:3000/widget 500 (Internal Server Error)"
I tried many things on it desperately but here is my current code:
My widget controller looks like this: (widget_controller.rb)
class WidgetController < ApplicationController
def show
@content = render_to_string(:partial => 'widget/embed', :layout => false)
end
end
My view using javascript (show.erb.html)
(function() {
document.write(<%= @content.to_json %>)
})()
The partial is not really important i think but here is an example: (_embed.erb.html)
<style>...</style>
<div class="widget-communication">
<div>Bla bla bla</div>
...
</div>
and for the last, in the routes.rb
...
match 'widget', to: 'widget#show'
...
So I tested in local to load my widget using this:
<script src="http://localhost:3000/widget" type="text/javascript"></script>