Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved formatting of markdown #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

Easily setup and use backbone.js (1.2.2) with Rails 3.1 and greater

##Version##
## Version

###Github master branch###
### Github master branch

Gem version : 1.2.2

Backbone version : 1.2.2

Underscore version : 1.8.3

###Rubygems###
### Rubygems

Gem version : 1.2.2

Expand All @@ -21,12 +21,12 @@ Backbone version : 1.2.2
Underscore version : 1.8.3


##Credits##
###Author###
## Credits
### Author
[Ryan Fitzgerald](http://twitter.com/#!/TheRyanFitz)
###Current Maintainer
[Manu S Ajith](http://twitter.com/manusajith)
###Contributors###
### Contributors
These [awesome people](https://github.com/codebrew/backbone-rails/graphs/contributors) helped to keep this gem updated

## Rails setup
Expand Down Expand Up @@ -102,27 +102,30 @@ You have one last step:

Edit your posts index view `app/views/posts/index.html.erb` with the following contents:

<div id="posts"></div>
```html
<div id="posts"></div>

<script type="text/javascript">
$(function() {
// Blog is the app name
window.router = new Blog.Routers.PostsRouter({posts: <%= @posts.to_json.html_safe -%>});
Backbone.history.start();
});
</script>
<script type="text/javascript">
$(function() {
// Blog is the app name
window.router = new Blog.Routers.PostsRouter({posts: <%= @posts.to_json.html_safe -%>});
Backbone.history.start();
});
</script>
```

If you prefer haml, this is equivalent to inserting the following code into `app/views/posts/index.html.haml`:

#posts

:javascript
$(function() {
// Blog is the app name
window.router = new Blog.Routers.PostsRouter({posts: #{@posts.to_json.html_safe}});
Backbone.history.start();
});
```haml
#posts

:javascript
$(function() {
// Blog is the app name
window.router = new Blog.Routers.PostsRouter({posts: #{@posts.to_json.html_safe}});
Backbone.history.start();
});
```

Now start your server `rails s` and browse to [localhost:3000/posts](http://localhost:3000/posts)
You should now have a fully functioning single page crud app for Post models.
Expand All @@ -133,7 +136,7 @@ Sample application can be found [here](https://github.com/manusajith/backbone-ra
####Overrides backbone sync function####
This gem overrides the backbone sync function. Check [here](https://github.com/codebrew/backbone-rails/blob/master/vendor/assets/javascripts/backbone_rails_sync.js) for details.

####With Rails 4:####
#### With Rails 4:
If you are using the default Rails 4 scaffold generators, you will need to adjust the default JSON show view (IE, 'show.json') to render the 'id' attribute.

default rails generated show.json.jbuilder
Expand Down