Rails for Django developers

1,783 views

Published on

Learning Rails for Django devs

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,783
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Rails for Django developers

  1. 1. Rails for Django Devs Agiliq.com - Building Amazing Apps
  2. 2. Why?1. Polyglot-ism is good2. Not a Django vs Rails tutorial Agiliq.com - Building Amazing Apps
  3. 3. Why?1. Rails is an influential framework and manylibraries have been inspired by it. Eg Backbone.2. Lot of great libraries and knowing rails wouldhelp you port them rather than start fromscratch. Eg we built Django-Merchant afterlooking through the API of active merchant.3. Eg. South, Arel Agiliq.com - Building Amazing Apps
  4. 4. Good ideas to pick up from Rails1. Asset Pipeline2. Better way to write template tags3. Simplified routing Agiliq.com - Building Amazing Apps
  5. 5. You say MTV, I say MVC app_name/models.py app/models/models_ name.rb app_name/views.py app/controllers/contro ller_name.rb templates/app_name/ app/views/view_nam template.html e.erb Agiliq.com - Building Amazing Apps
  6. 6. ModelsAuthoritative Sourceapp_name/models.pyDatabasemodels.py generate the SQL which is thenapplied to DBMigrations update the DB which is thenn usedto auto-generate schema.rb Agiliq.com - Building Amazing Apps
  7. 7. Relationships models.ForeignKey belongs_to, has_many models. has_one OneToOneField models. has_and_belongs_t ManyToManyField o_many Agiliq.com - Building Amazing Apps
  8. 8. Queryset etc User.objects.create() User.create(..) user.save() user.save! Model.objects.get(id=10) Model.find(10) Model.objects.filter(.. Model.where(.. conditions) conditions) Model.objects.order_by Model.order ("created_at") ("created_at") Agiliq.com - Building Amazing Apps
  9. 9. Routing urls.py config/routes.rb Regex based DSL based Agiliq.com - Building Amazing Apps
  10. 10. Some More Mappings. python manage.py runserver rails server python manage.py shell rails console python manage.py syncdb && python rake db:create && rake db:migrate manage.py migrate Agiliq.com - Building Amazing Apps
  11. 11. Things not to learn from Rail1. Too much autogenerated code2. Django forms API is much cleaner3. All models fields are nullable by default Agiliq.com - Building Amazing Apps
  12. 12. Resources1. rubyonrails.org2. guides.rubyonrails.org3. ruby.railstutorial.org Agiliq.com - Building Amazing Apps
  13. 13. About AgiliqPython Software consulting company. Small op Agiliq.com - Building Amazing Apps

×