Archive for Rails tips

Rails Render

Rails Render is a strong method that helps you to render your web pages. It comes with many flavors including:


1) Render action: render an action in the current controller, you can specify if you want layout printed or not

2) Render partial: renders part of your web page

3) Render template: render a page, the file path is relative to your application

4) Render file: absolute path is needed

5) Render text

6) Render Json


Comments (3)

Rails 301

This is how we issue 301 in Rails


Comments (3)

Rails API with the AJAX flavor

Ajax Rails API Here. I really enjoy using this API, you need to type what class, module or method you are looking to and it will get it to you. Then you get the details and enjoy rails development.

Comments

Rails performance tips

I have done some research through the weekend about improving Rails Applications performance. I would feel the the following few points need to be considered when we optimize rails applications for performance:

1) Avoid the use of dynamic URL generation (link_to, url_for) since rails needs to look up the routes table and that may take time. Just hard code the controller name and the action.

2) Try to avoid the excess use of helpers since it adds overhead.

3) You may consider to use Rails Bench to do some testing for you rails application performance.

4) You may consider to use memcached to cache your model and library computation results.

5) you may consider partial caching for your view partials.

6) try to optimize your database queries. If you use ActiveRecord find, be careful from computation intensive sql queries that returns to you a lot of data that you may not need. The method find may run many select statements for you.

These are very few tips, I will write about Rails performance in more details soon.


Comments (2)

Rails 404 (Not Found)

This is how you issue 404 in Rails:

Comments