开发者

How should I organize this Instapaper-like functionality in Rails?

Instapaper, if you don't know it, is a bookmarklet that saves your current URL to an account of yours. Essentially the bookmarklet loads a script on the page with parameters on that script's URL with somethin开发者_开发百科g like

z.setAttribute('src', l.protocol '//www.instapaper.com/j/Jabcdefg?u='
        encodeURIComponent(l.href)'&t=' (new Date().getTime()));
        b.appendChild(z);

So that's sending a request to a user-based, obfuscated URL along with the current page's URL.

I'm wondering how a similar service would be set up in a Rails app. The work is clearly being done by something called, perhaps, parser, which would probably be a model (it will run an HTTP request, parse, and save the data, for example). Can you route directly into a model? Do you need a controller over it to handle incoming requests? (I've tried this last bit, and it auto-loads a view, which I don't need/want).

I'd love some advice on this general architecture. Thanks!


I guess you cannot route directly to a model.
So, you need a controller over it to handle incoming requests.
And use "render :nothing => true" if you don't want the view to be sent to the browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜