Skip to content
Browse files

update website to talk about Sprockets

  • Loading branch information...
1 parent 420f710 commit fd671b9f97e2d7043909a27c637cec4ddd6fefa6 Francis Hwang committed Sep 17, 2011
Showing with 69 additions and 12 deletions.
  1. +20 −3 website/quick_start.markdown
  2. +49 −9 website/tutorial.markdown
View
23 website/quick_start.markdown
@@ -7,11 +7,13 @@ title: Quick start
This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href="/admin_assistant/tutorial.html">tutorial</a>.
</div>
-1) Add the gem to your Gemfile, and install it with `bundle install`.
+### Add the gem to your Gemfile
gem 'admin_assistant'
-2) admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include jquery, if you're not including it already.
+### Include admin\_assistant's CSS and Javascript in your layout
+
+admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include jquery, if you're not including it already.
<html>
<head>
@@ -20,8 +22,23 @@ This document assumes you are highly familiar with Ruby and Rails; if you are a
</head>
...
</html>
+
+If you're using Sprockets, which is the default in Rails 3.1, you should include the CSS and Javascript assets in the manifest files that you use for your admin layout.
-3) Setup an admin controller by attaching it to a model and using the admin layout:
+Javascript:
+
+ //= require admin_assistant
+ //= require jquery.tokeninput.js
+
+CSS:
+
+ //= require admin_assistant
+ //= require token-input
+
+
+### Setup an admin controller
+
+Use the admin layout, and call `admin_assistant_for` with the model class.
class Admin::BlogPostsController < ApplicationController
layout 'admin'
View
58 website/tutorial.markdown
@@ -7,20 +7,26 @@ title: Tutorial
This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href="/admin_assistant/quick_start.html">quick start</a>.
</div>
-1) Add the gem to `Gemfile` in the root of your Rails project.
+### Add the gem to your Gemfile
+
+This is found at `Gemfile` in the root of your Rails project.
gem 'admin_assistant'
-2) Install the gem locally.
+### Install the gem locally
$ bundle install
-3) admin\_assistant uses jQuery. You may already have jQuery installed for your project, but if not, you can get it like so:
+### Install jQuery if you need to
+
+admin\_assistant uses jQuery. You may already have jQuery installed for your project (it's the standard starting with Rails 3.1), but if not, you can get it like so:
$ curl http://code.jquery.com/jquery-1.6.2.min.js > \
public/javascripts/jquery-1.6.2.min.js
-4) If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this:
+### Create a separate admin layout (without Sprockets)
+
+If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this:
<html>
<head>
@@ -33,22 +39,56 @@ This document assumes you are a beginning Rails user; if you are familiar with R
</html>
If you've already created an admin layout, you should add the javascript references, and the call to `admin_assistant_includes`. This includes the standard CSS and Javascript that are packed with admin\_assistant.
-
-5) Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app.
+
+### Create a separate admin layout (with Sprockets)
+
+Rails 3.1 recommends Sprockets as the default asset packager. If you're using Sprockets, you'll probably want to create separate `admin.js` and `admin.css` manifest files. `app/views/layouts/admin.html.erb` will look like this:
+
+ <html>
+ <head>
+ <%= javascript_include_tag "admin" %>
+ <%= stylesheet_link_tag "admin" %>
+ </head>
+ <body>
+ <%= yield %>
+ </body>
+ </html>
+
+And you will add admin\_assistant's assets to the manifest files, which you will most likely put at `app/assets/javascripts/admin.js` and `app/assets/stylesheets/admin.css`.
+
+Javascript:
+
+ //= require admin_assistant
+ //= require jquery.tokeninput.js
+
+CSS:
+
+ //= require admin_assistant
+ //= require token-input
+
+### Create an admin controller
+
+Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app.
./script/generate controller admin/blog_posts
+
+### Edit your admin controller
-6) Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model:
+Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model:
class Admin::BlogPostsController < ApplicationController
layout 'admin'
admin_assistant_for BlogPost
end
-7) If you were already running your Rails app with `./script/server` etc, you should restart it.
+### Restart your Rails app
+
+If you were already running your Rails app with `./script/server` etc, you should restart it.
+
+### Check out the controller
-8) Visit `/admin/blog_posts` in your browser and you'll see something like this:
+Visit `/admin/blog_posts` in your browser and you'll see something like this:
![index](/admin_assistant/img/blog_posts-index.png)

0 comments on commit fd671b9

Please sign in to comment.
Something went wrong with that request. Please try again.