I’ve been trying to wrap my head around this for a while now, and have been researching on the web with little success. I can’t be the only one, right?
How do you create a CMS within a namespace using Backbone?
In rails it is relatively simple, but adding backbone into the equation seems tricky.
Here’s my basic application so far:
Relative Gems
gem 'rails', '3.1.0.rc4'
gem 'devise'
gem 'rails-backbone', '0.5.0'
Basic App Structure
/app
/assets
/javascripts
/backbone
/controllers
- posts_controller.coffee
/models
- post.coffee
/templates
/posts
- edit.jst.ejs
- index.jst.ejs
- new.jst.ejs
- post.jst.ejs
- show.jst.ejs
/views
/posts
- edit_view.coffee
- index_view.coffee
- new_view.coffee
- post_view.coffee
- show_view.coffee
/controllers
/admin
- admin_controller.rb
- posts_controller.rb
- application_controller.rb
- posts_controller.rb
/models
- post.rb
/views
/admin
/posts
- index.html.haml
/posts
- index.html.haml
Routes.rb
namespace :admin do
resources :posts
root :to => "posts#index"
end
resources :posts
root :to => "posts#index"
Do you have to create another “admin” directory within the backbone views and controllers like the rails structure? Like rails, do they reference the same ‘un-namespaced’ backbone post model?
How would you then route your backbone structure to pull the correct views while limiting access to edit, new, delete duties – and how would they be referenced?
For example, the normal backbone controller class is defined like…
class Appname.Controllers.PostsController extends Backbone.Controller
Would this be the proper way to define the namespaced controller?
class Appname.Controllers.Admin.PostsController extends Backbone.Controller
There are a lot of questions here, any help would be greatly appreciated.
Try taking a look at the latest version of backbone. Controller has been renamed to Router. That may help some.