I’m trying to make a widget for a page, that will go on other people’s
pages if they choose to do so.
What I am wanting to do, is have a resource like
map.resource :widget
So that localhost/widget is mapped to :controller => widget, :action
=> show, as is default with singular resource.
That way if someone browses to localhost/widget, they can see some
html/erb explaining how to use the widget, and then if they
in there webpage, they can have the widget rendered on their page.
I thought I might be able to do this, by setting a respond_to in the
show action like this:
def show
…
…
respond_to do |format|
format.html { do some normal html rendering }
format.js { render the widget }
end
end
So then I created a file called show.rjs, and tried writing some very
basic rjs, just to see if it would work, and it totally did not. So I
tried a bunch of different approaches in the rjs file, especially the
page << ‘raw javascript’ kind of thing, I really thought that was
going to work, but no deal.
Also, I tried renaming show.rjs to just show.js, same thing nothing.
Does anyone know what I am doing wrong here? Does anyone know what a
better solution for me would be?
Thanks for listening.