Very interresting survey about Rails about hosting, user experience, deployment, SCM, performance/exception monitoring…
That shows a little more about the current state of Rails.
There is a free and fun way to learn ruby: Why’s (poignant) Guide to Ruby
The book is full of humour and it makes it really easy and entertaining to read without losing the main goal of the book: learning ruby.
Although it is simple to read, on should have really good knowledge and understanding of OOP.
I received this link form ruby_news’s twitter:
That’s especially rails related, but I’ve been looking for a good DataGrid (spreadsheet) js API and there is the best I’ve seen so far:
Nitobi has others JS API: tree, calendar… but I did not have time to look at them all.
For those who are missing refactoring tools in their favorite Text Editor, salvation is coming: Rfactor and its TextMate bundle.
Rfactor is a gem and hopefully there’ll be bundles or plugins for other text editor (Vim, emacs …)
Full Story> Rfactor: Ruby Refactoring for your loved editor
Most of the time, in my projects, I need a separated administration area: http://teste.local/admin/*
For those who doesn’t know resource_controller (r_c) yet, please visit: Restful Controllers with resource_controller. I’ll never have a Rails app not using it, that’s for sure!
The goal here is to create a resource called Post and access it using http://teste.local/admin/posts .
My first thought was to try:
script/generate scaffold_resource admin/Posts title:string content:text
But it created things in a way I did not like:
- app/models/admin/posts.rb ( I really do not want my model to be in the admin folder)
- db/migrate/20090119032314_create_admin_posts.rb / create_table :admin_posts (In fact it created a admin_posts table … :-( )
I then resigned myself to the fact that I’ll have to generate in the “normal” way and then hack the generated files to adapt to what I wanted to do. Here we go:
script/generate scaffold_resource Posts title:string content:text
route map.resources :posts
I then changed the following:
app/views/posts to app/views/admin/posts
app/controllers/posts_controller.rb to app/controllers/admin/posts_controller.rb
app/helpers/posts_helper.rb to app/helpers/admin/posts_helper.rb
test/functional/posts_controller_test.rb to test/functional/admin/posts_controller_test.rb
Don’t forget to change add Admin:: in all the .rb files that you moved.
Last thing to change is the route to the Post resource:
#Has to be replaced by:
map.namespace :admin do |admin|
admin.resources :posts #Directs /admin/posts/* to Admin::PostsController (app/controllers/admin/posts_controller.rb)
Namespaces configuration is pretty straight forward and there is loads of articles and websites explaining it. So if you’re confused about this, google it! ;-)
That should do it. Now you can access http://teste.local/admin/posts
Have a look at the Rails reserved words: Rails Reserved Words
On the page there is reserved words and some that can cause problems. I had a nasty waste of time trying to use resource_controller to create a Template resource. Template is not a reserved word, but you can’t have a Create action for a template controller…