Emberjs + Rails seamlessly integrated? - ruby-on-rails

Emberjs is great but it require to re-write all routes and models if I change something on Rails. Is there a way to get all Emberjs's routes generated by Rails? So if I change a route on Rails, automatically, it generate all Emberjs's routes? The same thing to share model's validation and other things..
Or are there others JS framework for Rails?

I don't know what you have tried so far, but one of the best ember-rails integration tools out there might be https://github.com/emberjs/ember-rails. It has boostrap commands like: rails g ember:bootstrap which does some boilerplate code generation.
Hope it helps.

Related

where are the auto generated routes in rails scaffolding?

Alright, I'm starting to learn rails and so far im really turned off by how much is auto generated and happening behind the scenes without me knowing. I generated scaffolding for posts. and it auto created routes allowing me to edit and see posts (/posts, /posts/:id/edit, /posts/:id/show....etc) When I go into config/routes.rb I see absolutely no mention of these routes. even though they work. Where are these routes? and where can I add custom routes if the ones for the controller are not in routes.rb?
When you run rails generate scaffold post, rails will generate models, controllers, tests, routes, stylesheets etc.
Rails tells you what files it just generated, you can see it in terminal.
In routes.rb there will be a line
resources :post, this is a shorthand for all RESTful actions that were generated in the controller.
You can declare custom routes in the routes.rb file. I.e.:
get 'my_path'=> 'my_controller#my_action'
In General, Rails can do a lot of stuff for you, and you can avoid repeating default behaviour over and over again. But you can also do most stuff yourself, without Rails magic.
Instead of using scaffolds, just run rails generate controller controller_name action1 action2 (..). You'll end up with just a controller, no automatic views, no automatic model etc.
Or you can just create all files and register your components yourself.
The Rails Guides are a good starting point for understanding the magic.

What is the difference between default scaffold and nifty:scaffold?

I am trying to generate a layout which I can use between my rails webapp and mobile versions. I have been using nifty-generator, but it says the generated files are identical to what was generated by rails3 new application creation.
What's the major difference between default scaffold and nifty:scaffold?
If you visit the Github page (https://github.com/ryanb/nifty-generators) for the project under 'Troubleshooting and FAQs' it answers a few questions including this one. The response given there is:
One of the primary differences is that nifty:scaffold allows you to
choose which controller actions to generate.
rails g nifty:scaffold post name:string index new edit
There are a few changes to the generated code as well, such as no XML
format by default.
It also offers support for HAML, Shoulda, and RSpec.
Once you get a handle on the code that Rails needs in its RESTful controllers I would highly recommend using Inherited Resources (https://github.com/josevalim/inherited_resources) instead. It really helps DRY up your controllers.

Migrate from restful_authentication to devise

i've been using rails 2 for a project and restful_authentication with it. Recently, i changed that project to rails 3 and i found out about devise, that to my eyes seems a much better solution that restful_authentication.
Therefore, i decided that it would be a good idea to migrate to devise, but it seems that the procedure is pretty tedious and error prone. I would like to ask you if you know of any good resource that describes the procedure, because doing it from scratch is a bit of a hassle.
rails generate devise:install
rails generate devise User
rake db:migrate
That's all there is for now, you get routes and functionality like /users/sign_(in|out|up) from start.
Resources:
Railscasts "Introducing Devise"
Devise Readme
Example application
You can try Migrating from Restful Authentication to Devise, but so far nothing for me. :(

Does anyone actually use Ruby On Rails scaffolding?

I think I am missing the point of scaffolding, does anyone use RoR scaffolding and if so can they point me to any specific examples of how they use it?
I am a big sass and compass fan, is it possible to incorporate this into scaffolding?
Yes, scaffolding as a generator is useful. It creates the files you need, then you customize them. I don't think anybody uses the active scaffolding anymore, I for one discourage it. But, as I said, the generator is usesful
rails g scaffold product price:float title:string description:text
as it creates the migration file, model and controller you need either way. I don't like the default tests (rspec has better test generators) as I value tests too much to have stupid autogenerated ones.
As for the sass and/or compass, I don't use generators for that, but you may try something like http://github.com/darthschmoo/rails-compass-sass-generator I don't autogenerate those as the views are always highly customized.

Why did Ruby on Rails deprecate the scaffold method

I am learning Ruby on Rails so I'm sure I'll find this out sooner or later.
Why would the scaffold method be deprecated in version 2 of Rails?
The scaffold method went against the spirit of scaffolding, which is meant to give you a starting point that you are supposed to build upon for your own needs. By generating the scaffold dynamically, there is nothing for you to edit.
The new way with the scaffold generator lets you edit the scaffolded files so you can use it to build what you actually need.
I am assuming you are referring to Dynamic Scaffolding, as the scaffold generator is still around and going strong.
David Heinemeier Hansson is on record as saying that Dynamic Scaffolding looked great in demos, but since the whole point of Dynamic Scaffolding was to teach people to use rails, abstracting it away in a single line of code was more a curse then a blessing, as no one uses Dynamic Scaffolding in production code . . . just for demos and tutorials.
If you have a copy of AWDWR handy, you can read about his whole explanation on about p81 in the latest(3rd) edition (I didn't want to copy paste).
You can still:
script/generate scaffold model_name
to generate your scaffolded model.
There is however still a Rails plugin out there that will do just what the scaffold method did before. It's called ActiveScaffold.
Because people thought it was supposed to be used for production, which would be a horrible idea. Instead you generate a scaffold which you can then easily edit and get it production ready from there.

Resources