patcito / angularjs_scaffold

A rails plugin for scaffolding views using Angular.js, Twitter bootstrap and font-awesome.
http://blog.ricodigo.com/blog/2012/10/14/announcing-the-release-of-angularjs-scaffold/
MIT License
317 stars 41 forks source link

Does not work with Rails4 #13

Open hipertracker opened 11 years ago

hipertracker commented 11 years ago

The gem specs are still dependent on Rails 3 :(

patcito commented 11 years ago

To be fair, rails4 hasn't been released yet but I'll have a look.

kgathi2 commented 11 years ago

XSRF token does not get relayed properly. May be changes in rails routing

djones commented 11 years ago

Confirmed this is still an issue with Rails 4 rc1

lgs commented 11 years ago

... I can install on Rails 4 ( rails g angularjs:install ) and I can create and see posts, but DELETE and EDIT don't work :

gem 'rails', '4.0.0'
gem 'angularjs_scaffold',  :git => "https://github.com/patcito/angularjs_scaffold.git"

then I can also do :

 2066  rails g scaffold Post title:string body:string
 2067  rake db:migrate
 2068  rails g angularjs:scaffold Posts

now I can create and see posts, but as soon you try to DELETE them, it fails with a routing error :

Started GET "/posts" for 127.0.0.1 at 2013-07-06 18:41:47 +0200
Processing by PostsController#index as JSON
  Post Load (0.2ms)  SELECT "posts".* FROM "posts"
  Rendered posts/index.json.jbuilder (4.5ms)
Completed 200 OK in 10ms (Views: 8.5ms | ActiveRecord: 0.2ms)
Started DELETE "/posts" for 127.0.0.1 at 2013-07-06 18:41:53 +0200
ActionController::RoutingError (No route matches [DELETE] "/posts"):
  actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  railties (4.0.0) lib/rails/engine.rb:511:in `call'
  railties (4.0.0) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /home/lsoave/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  /home/lsoave/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  /home/lsoave/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
  Rendered /home/lsoave/.rvm/gems/ruby-2.0.0-p0@rails-4.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms)
  Rendered /home/lsoave/.rvm/gems/ruby-2.0.0-p0@rails-4.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_route.html.erb (1.9ms)
  Rendered /home/lsoave/.rvm/gems/ruby-2.0.0-p0@rails-4.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_table.html.erb (3.6ms)
  Rendered /home/lsoave/.rvm/gems/ruby-2.0.0-p0@rails-4.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (41.0ms)

as well as you try to EDIT, fails presenting an empty form instead of the corresponding post to edit :

Started GET "/assets/posts/edit.html" for 127.0.0.1 at 2013-07-06 18:43:43 +0200
Started GET "/posts" for 127.0.0.1 at 2013-07-06 18:43:43 +0200
Processing by PostsController#index as JSON
  Post Load (0.2ms)  SELECT "posts".* FROM "posts"
  Rendered posts/index.json.jbuilder (1.8ms)
Completed 200 OK in 8ms (Views: 6.0ms | ActiveRecord: 0.2ms)
aripoya commented 10 years ago

in rails 4 you can add some code like this:

class ApplicationController < ActionController::Base protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format =~ %r{application/json} } end

this solution base from :https://coderwall.com/p/8z7z3a