Dynamic content edition for rails
Add this line to your application's Gemfile:
gem 'olala'
And then execute:
$ bundle
$ rails g olala:install
$ rake db:migrate
Add require olala
at the end of app/assets/javascripts/application.js
Add this in application.html.erb
before </head>
tag
<% if session[:admin] %>
<link rel="stylesheet" href="/aloha/css/aloha.css" type="text/css">
<script src="/aloha/lib/require.js"></script>
<script src="/aloha/lib/vendor/jquery-1.7.2.js"></script>
<script src="/aloha/lib/aloha.js" data-aloha-plugins="common/ui,common/format,common/table,common/list,common/highlighteditables,common/link,common/image,common/block,common/undo"></script>
<% end %>
<%= javascript_include_tag 'application' %>
Change your body tag to: <body class='<%= 'admin' if session[:admin] %>'>
Load the temporary auth mechanism (in application_controller.rb) :
include Olala::CustomAuth
Make sure that you have:
- jquery in your javascript dependencies'
- a database with activeRecord (pg, mysql, sqlite), jquery
Replace each block that you want to make dynamic:
<p>Static text</p>
to
<p>Olala::editable('my_title', 'Static text')</p>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request