# BetterFrame Everyone hates iframes. This is why this rails plugin exists. You'll get a much smoother usage of your app when embedded. Basically what this plugin does is the following: * Inject your html code onto the foreign website. * Handle all events (link clicking, form submitting) with javascript. * Write the browser history to make the navigation as normal as possible. * Write rails path + parameter onto the foreign site. ## Installation Add this line to your application's Gemfile: ```ruby gem 'better_frame' ``` And then execute: $ bundle ## Usage ### Internal (in your rails app) **NOTE: you need to make all your forms `remote: true` as this should not redirect to the rails app if you're submitting a form. To start, you need to mount the engine in your rails routes: ```ruby # config/routes.rb Rails.application.routes.draw do mount BetterFrame::Engine => "/better_frame" ... end ``` As this only works with setting the `Access-Control-Allow-Origin` header, you'll need to include a concern to your controllers to make it available for better_frame to load. (You also may include it in your ApplicationController if you want.) ```ruby # app/controllers/examples_controller.rb class ExamplesController < ApplicationController include BetterFrameable end ``` You'll have to set the `Access-Control-Allow-Origin` using the `BETTER_FRAME_ORIGIN` environment variable. $ export BETTER_FRAME_ORIGIN=http://example.com Or using [dotenv](https://github.com/bkeepers/dotenv) ``` BETTER_FRAME_ORIGIN=http://example.com ``` Side note: If you have `protect_from_forgery with: ...` in your controller you have to delete that because of the cross site origin requests. ### External (on your website which should embed the rails app) **NOTE: you need to have jQuery on the website which is embedding your rails app** On your website do the following: ```html
``` In `