Coder Social home page Coder Social logo

backbone-on-rails's People

Contributors

andrewhubbs avatar billychan avatar brockers avatar dahal avatar derekprior avatar drale2k avatar jwarzech avatar kchung avatar manzhikov avatar meleyal avatar ncolgan avatar pklingem avatar sascha avatar taavo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone-on-rails's Issues

Unnecessary Dependencies

Hi,
#57 introduced dependencies into the gemspec that are not needed. activeresource is not a core rails dependency anymore (since v4) and requiring it forces a large dep (since it pulls in rails-observers as well) to be included in the bundle even if it isn't being used. I don't believe this gem requires any dependencies other than railties.

That PR also mistakenly blamed the rails dependency in this gemspec for failing to boot. The more likely cause was in config/application.rb, rails/all was being required instead of the core parts of rails that were needed.

To test this:

rails new foobar --skip-active-record
# Edit Gemfile and add:
# gem 'backbone-on-rails', '< 1.1.1.0'
bundle install
bundle exec rails s

cc/ @brockers

rails g backbone:install did not create backbone.js or underscore.js

~/railsapps/bkbone$ rails g backbone:install
append app/assets/javascripts/application.js
create app/assets/javascripts/collections
create app/assets/javascripts/models
create app/assets/javascripts/routers
create app/assets/javascripts/views
create app/assets/templates
create app/assets/javascripts/bkbone.js.coffee

Eco gem creating problem

When i did
gem install backbone-on-rails

it stopped with this error:
Unable to resolve dependencies: eco requires eco-source (>= 0)

i checked it and eco gem depends on eco-source gem and there is eco-source --pre gem.

No blank lines in manifest

Rails 3.2.1 has the following warning in the default application.js

// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

Make sure we don't add any blank lines when adding the requires.

--namespace option for generators

As of 0.9.2.2 the --namespace option for the generators was removed as I was finding it difficult to test.

If there's enough interest / requests for this feature I'll be happy to add it back.

Add backbone in Rails Engine

I have 2 engines in rails application. I want to add backbone in 1 engine. how to do it? If I run
rails g backbone:install

it will not add backbone to my engine.

Router not functioning

I am trying to implement this gem but when i try to initialize a new instance of the Router Class in the js file. I get this error Uncaught TypeError: undefined is not a function. This is the js file

window.Library =
Models: {}
Collections: {}
Views: {}
Routers: {}
initialize: ->
@router = new Library.Routers.Books()
Backbone.history.start()

$(document).ready ->
Library.initialize()

underscore.js is stuck at 1.3.1

This may be a basic thing that I don't get yet about the asset pipeline. But for some reason even though I have the latest version of this gem installed – I am getting errors that when I debug in webkit, I can see are due to the underscore version being 1.3.1.

How do I get that file to update 1.3.3 as it should be? Any help appreciated... MUCHO!

Rails 3.1.2 breaks ../templates path

Sprockets complains it can't find the file:

throw Error("Sprockets::FileOutsidePaths: /Users/meleyal/code/test/app/assets/templates/foo/index.jst.eco isn't in paths: 

Install generator assumes //= require_tree in application.js

If you don't have the line //= require_tree in your app/assets/javascripts/application.js[.coffee] file and run the generator, backbone-on-rails doesn't add the dependencies and quietly swallows the error(?). If I hadn't watched the Railscast, I wouldn't have even noticed this. Kills core functionality.
If I use the lib in more than one project, I will submit a patch.
Maybe is what caused Issue #2? Speculation of course ;)

update error (Gem::UnsatisfiableDependencyError)

Hey guys,

While I was trying to update my gems in local, I got the error below:

❯ gem update --system && gem update
Latest version currently installed. Aborting.
Updating installed gems
Updating backbone-on-rails
ERROR:  While executing gem ... (Gem::UnsatisfiableDependencyError)
    Unable to resolve dependency: 'eco (>= 0)' requires 'eco-source (>= 0)'

Any ideas?

scaffold file naming changed

I noticed that when i scaffold a resource, lets say "users", earlier it named files like

"users_index.js.coffee" and "users_router.js.coffee"

now it does

"index.js.coffee" and "users.js.coffee"

Is this by accident?

Generator not working with Engines

I have a mountable Engine (Rails 3.2.12) where I tried to install backbone-on-rails, but after running rails g backbone:install it generates a file called nil_class.js.coffee. This is because it cannot find the Engine's name.

Update to Backbone 1.2.1

We've run into a couple of bugs in 1.2 that appear to be resolved in 1.2.1. Any plans to bump the version soon?

I'm happy to attempt a pull request for this if desired.

Handlebars Template Name Causes Error

Using Handlebars, if I run rails generate backbone:scaffold planet --template=hbs it will create the template app/assets/templates/planets/index.hbs and add template: JST['planets/index'] to the generated view. However, when it tries to load that template I get the error "Uncaught ReferenceError: JST is not defined" unless I change the template name to index.jst.hbs. Should the generator add .jst to the file extension so that it works correctly or is there something else wrong?

JST template path is wrong

The generated template path is wrong. It currently generates:

template: JST['templates/todos/index']

But templates is added directly to the assets path, so it should just be:

template: JST['todos/index']

activerecord dependency issue

I have a couchdb rails application I was working on that specifically needs to disable the active_record dependency to run. Something to this effect:

rails new YourProject --skip-active-record

Tried using backbone-on-rails and for file generation it seemed to work, but as soon as I try to access my default page it crashes due to activerecord trying to access the config/database.yml file (which doesn't exist on non-active_record project.) This only happens when using backbone-on-rails.

Does backbone-on-rails have some kind of active_record dependency that causes it to load?

JST index templates not available by name

I have a Backbone View ReviewsIndex, wrote the template in templates/reviews/index.jst.ejs, and attempted to give it the template JST["reviews/index"], but this was said to be undefined.

Hours later, I discovered the JST["reviews"] alias. Which is nice, but not being able to invoke it by name as expected caused me endless headache. Please fix this undocumented feature.

EDIT: I'm (reluctantly) using Javascript, not Coffeescript.

Add json2

Should this not come packaged with json2.js since that is a requirement for using Backbone? I just got bitten by this, I assumed that this gem would handle all dependancies for backbone.

Other than that thanks for a really useful gem.

Sprockets Error can't find backbone/backbone/

When the below is written to application.js as part of the backbone generator install,

//= require backbone/backbone

you get a Sprockets error. When you remove it, everything seems to work fine...What is the "backbone/backbone" intended for?

Route callback not executing

Hi, I'm walking through the Railscasts backbone #1 episode, but using Rails 4.0.0 and Ruby 2.0. At this point, requesting the root should display an alert dialog with message 'home page', but I'm not getting that. Here's my code:

entries.router.js.coffee

class Raffler.Routers.Entries extends Backbone.Router
  routes:
    '': 'index'

    index: ->
      alert 'home page'

raffler.js.coffee

window.Raffler =
  Models: {}
  Collections: {}
  Views: {}
  Routers: {}
  initialize: -> 
    new Raffler.Routers.Entries()
    Backbone.history.start()

$(document).ready ->
  Raffler.initialize()

In the rails application, I'm rooting to "main#index" which is correctly rendering the view with the div showing "loading", but I'm not getting the alert dialog.

I'm not seeing any javascript errors in either Firefox 12 or Chrome ver. 28.0. When I step through the code, I can see that Backbone.history.start() is returning true, indicating that the url matched the route.

I removed the turbolinks gem from my bundle (and also from application.js and the layout), but that doesn't seem to have been the issue.

Can anyone spot what I'm doing wrong or recommend some way that I can debug this?

Add option to generate Mocha/Jasmine tests

As I am going through the Peepcode tutorials (which discuss backbone in the context of Sinatra/JS) by using backbone-on-rails, I am discovering that support for tests or specs is missing. That could be useful for playing with models in the web-browser.

To get this running, one might propose to create a /test-backbone directory with a SpecRunner.html and the Jasmine-lib.
@topfunky uses a reference in the SpecRunner.html:

<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine-html.js"></script>

Additionally, the collections, models and specs should be loaded, e.g. such as these:

<script src="../app/assets/javascript/Tunes.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/TunesSpec.js"></script>

Not a big issue, but eventually interesting to note.

Can't install gem

when I do gem install backbone-on-rails

I'm getting this error:
ERROR: Could not find a valid gem 'eco-source' (>= 0) in any repository ERROR: Possible alternatives: to_source, chsource, taosource, epf-source, outsource

Problems getting eco templates working

I'm new to Backbone.js as well as your gem, so forgive me if this is a stupid question. I'm following through the Railscast on using backbone-on-rails, but can't seem to get the eco templates to render. And I don't see any eco library being downloaded in the browser. Is this supposed to be required somewhere? I noticed the gem is added as a dependency but there weren't any instructions in the readme about needing to set it up.

class MyApp.Views.PagesIndex extends Backbone.View

  template: JST['pages/index']

    render: ->
        $(@el).html(@template(herevar: 'variable goes here'))
        this

malformed application.js manifest entries

I was following the RailsCast tutorial #323, which is part one of the backbone-on-rails set. While following along in the tutorial, I ran the following command:

rails g backbone:install

The command generated the standard folders for models, routes, collections, and views, but it also generated manifest entries into my application.js file which are as follows:

//= require jquery
//= require jquery_ujs
//= require_tree .
//
// begin backbone generated entries
//
//= require underscore
//= require backbone
//
//= require .//raffler
//
//= require_tree ../templates/
//= require_tree .//models
//= require_tree .//collections
//= require_tree .//views
//= require_tree .//routers
//
// end backbone generated entries

As you can see, the folder syntax for the models, etc. are malformed, and will cause js uncaught exception errors if not repaired manually.

issue with eco dependency

I am packaging backbone-on-rails for debian and it has a dependency on eco (do you really use it?) but I cannot generate eco.js from the coffee script sources (because any minified javascript should be generated on debian from their sources and eco.js provided by eco-source is minified).

see https://lists.debian.org/debian-ruby/2015/06/msg00038.html for errors. Can you suggest how to proceed?

document ready fxn not firing in Safari

Backbone events are not firing in Safari. I have peeled it back to the main application.js.coffee file. Even with something as simple as an alert firing on document ready fails in Safari but works in all other browsers.

I have found that on initial page load in safari the event does not fire, but if you refresh the page it fires as expected.

Rails 3.2.2

Hi with a clean installation of rails 3.2.2 and following instructions found in the readme i get this error from sprockets:

couldn't find file 'underscore'

Backbone-on-rails demo app

Hello,

this is not really an issue, but more a request or idea to make learning to use backbone easier. E.g. as I am starting to play with the gem, I am having a bit of a problem to understand how to combine multiple collections and views for a simple one-page application, and how to serve and process the json data in rails in the background.

I was thinking that a demo application for a blog could be a nice help to get started with the gem.
I have created a small backbone-based-blog template here: https://github.com/mulderp/backbone_testapp

What do you think? Would it be helpful for other to gather feedback on the usage of backbone and rails?

backbone:install with --namespace option causes Error

I'm not entirely sure that this is backbone-on-rails' fault, but I just saw this error come up after installing the gem for the first time and running backbone:install with the --namespace option and got this error:

rails g backbone:install --namespace document_library
      append  app/assets/javascripts/application.js
      create  app/assets/javascripts/document_library/collections
      create  app/assets/javascripts/document_library/models
      create  app/assets/javascripts/document_library/routers
      create  app/assets/javascripts/document_library/views
      create  app/assets/templates/document_library
      create  app/assets/javascripts/document_library/backbone_test_project.js.coffee
/home/caleb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:581:in `block in process_args': invalid option: --namespace (OptionParser::InvalidOption)
    from /home/caleb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:in `new'
    from /home/caleb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:560:in `process_args'
    from /home/caleb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:591:in `run'
    from /home/caleb/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'

Feel free to close if you think this is a minitest or a Rails issue rather than one with backbone-on-rails.

Add a path prefix / namespace option to the generators

The generators should accept a path so that:

rails generate backbone:scaffold solar_system/planet

Would generate:

app/assets/
├── javascripts
│   ├── application.js
│   └── solar_system
│       ├── test_app.js.coffee
│       ├── collections
│       │   └── planets.js.coffee
│       ├── models
│       │   └── planet.js.coffee
│       ├── routers
│       │   └── planets_router.js.coffee
│       └── views
│           └── planets
│               └── planets_index.js.coffee
└── templates
    └── solar_system
        └── planets
            └── index.jst.eco

Backbone 0.9.2 released

Hey, just in case you missed it, Backbone 0.9.2 was released yesterday :)

Edit

Just submitted a pull request

Does it work with Rails engines? (can't find underscore)

I added backbone-on-rails as a dependency in my gemspec, but when my engine's javascript manifest tries to require underscore, it fails to find it. As far as I understand, backbone-on-rails is a rails engine itself and provides underscore and backbone through its vendor directory which is automatically loaded as part of the asset pipeline. This has worked well for me in normal Rails apps, but now I'm trying to develop a Rails engine which depends on backbone, and am having trouble trying to get this working correctly. I didn't actually try the install generator because I wasn't sure that it would work, so I copied all the asset directories from another project where I had it working.

Is there something else that I need to do in order to load underscore and backbone besides adding backbone-on-rails as a gem dependency?

Ruby 1.8.7 compatibility?

Hi,

I'm having trouble installing into an app running ruby 1.8.7. Is the Gem compatible?

I have used in another app running 1.9.2 without the issue.

Thank you
Ryan

generators for engines

Hey,
just noticed that it would be nice if the generators pickup the engine env. currently i get a:

No such file or directory - /rails_app/vendor/engines/engine_name/app/assets/javascripts/application.js (Errno::ENOENT)

error, if i run the generators inside an engine.

above should be detect the engine namespace:

/.../rails_abb/vendor/engines/engine_name/app/assets/javascripts/engine_name/application.js

Add "model" option to collection scaffold

When generating a scaffolding, it would be nice if the collection included a model option set to the generated model. Otherwise it may not use that model.

class App.Collections.People extends Backbone.Collection
  model: App.Models.Person

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.