Friday, 25 May 2012

Best file comparision utility or tool

Hi,

In the application/project development we may have situation where we need to compare the two similar files to know what changes have been made in them.

I have used recently one of the best tool to compare files and folders and which made easy for me while integrating the code while working with multiple developers on same project.

Here is the tool:  Beyond Compare

Its a tool where we can compare two files or folders with the same and name and it shows the difference of code/text by comparing them. We can also push the newly added code from one file to another with same just by single click.

You can download the software form here.

Download Beyond Compare


Thank You,
Uma Mahesh.

Thursday, 24 May 2012

Count relation between models in rails using counter_cache option

I have a User with has_many articles. In order to display(count) number of articles created by user I will call @user.articles.count.
It will internaly run sql query on articles table. In order to eliminate the external query for displaying the count(i.e number of articles) active record associations provides usefull option for that.


Say a User has_many articles. In the articles model, add a line blongs_to :user, counter_cache: true. Add an integer column to the user table named articles_count. Whenever you create a article, the counter will be updated. See http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-belongs_to (:counter_cache section).

:counter_cache
Caches the number of belonging objects on the associate class through the use of increment_counter and decrement_counter. The counter cache is incremented when an object of this class is created and decremented when it’s destroyed. This requires that a column named #{table_name}_count (such as comments_count for a belonging Comment class) is used on the associate class (such as a Post class). You can also specify a custom counter cache column by providing a column name instead of a true/false value to this option (e.g., :counter_cache => :my_custom_counter.) Note: Specifying a counter cache will add it to that model’s list of readonly attributes using attr_readonly.


Thank you,
Uma Mahesh

Wednesday, 23 May 2012

ruby on rails coding standards

Hi,

Here is the good resource where you can learn ruby on rails coding standards.

https://github.com/bbatsov/ruby-style-guide

The above guidelines have been followed by github team while developing the github application in ruby on rails.

Follow the below standards to have good style of code.

https://github.com/bbatsov/ruby-style-guide

Thank You,
Uma Mahesh.

Monday, 7 May 2012

rails different datatypes in different databases

Here are the list of datatype that can be used in rails migrations and its respective database support types.


How to hide filters in the active admin view

Hi,

I am working with active admin customisation for one of my project. In that I need to hide the filters in the list views.

This can be done with simple configuration as shown below

ActiveAdmin.register Product do

config.clear_sidebar_sections!

end

The above configuration will make filters not to display in the list view.

Thank You,
Uma Mahesh

How to hide API & Downloads links in the active admin

Hi,

I am working with active admin customisation for one of my project. In that I need to hide the API & Downloads links in the list views.

I have searched for it making it configurable at controller level. But I came to see there is no such provision.

By goggling I found solution as this can done through css path. I.e making the css class for that text to be hide.

Here is the style that need to be added in the active admin css style sheet.

In app/assets/stylesheets/active_admin.css.scss

.index #active_admin_content #index_footer {
  color: white;
  a {
    display: none;
  }
}

This will make the download links hide in the view.

Thank You,
Uma Mahesh.

Tuesday, 1 May 2012

What is the future of Ruby on Rails developer ?

What is the future of Ruby on Rails developer ?

 

Here are the list of answers I came across in social networking sites. 

 

Andrew McElroy  I think JavaScript is going to be the new 'rockstar'. I can forsee a rails 4.3 or 5.0 version which essentially compiles all the ruby code down to javascript and in essence eats nodeJS' lunch. It is already possible to execute javascript in ruby context. Also, it is possible though a different library to go the other direction. Clearly, Javascript is seeing a lot of attention these days. One more prediction, CoffeeScript doesn't so much go away as become merged into a future ECMAScript.
It's worth pointing out that with the inclusion of the asset pipeline in rails 3.1, you must now have a Javascript Runtime engine on the server side. Currently therubyracer gem seems to be the most popular. I think this dependency is a pretty telling future indicator.

One thing is for certain, a future rails app will be expected to have a server side model2 (what we normally in rails think of MVC) structure, and the client side will have its own true MVC be it angularJS, Backbone, EXT, etc.

It will be interesting to see where all this goes.

TL;DR: ruby has a future, maybe within the execution context of JS, but it isn't going away.

 

 

 

 

Nathan Van der Auwera  I see on the one hand that rails is still growing. More and more companies are switching to rails. Rails has the advantage that server-code and views are prepared in ruby: one language one platform. 

But, in practice, to get a snappy-feeling website, you already had to do a lot of javascript.

Now, with frameworks like Backbone.js/spine.js/ember.js/batman.js ... we move to a bigger client, a cleaner server. Rails will still have it's place, with the asset-pipeline and such. But on the other hand sites will do more smaller requests. So I think a server like node.js then is becoming very interesting. 

I definitely think you should learn these, just to know it's strengths and weaknesses. 

Looking further down the road, i think haskell with a webserver like yesod/warp is also looking very promising.

 

 

Rogier Svensson Krona  As said before future is never known. However besides the technical side I would like to add some comments on the business side. Rails is very community driven (at least in Scandinavia) and that somehow means that there is less activitity on the business side. While Java and many other tools, languages, frameworks etc. is "familiar as words" even for the decisionmakers of established companies, Rails is quite unknown. I think Rails has to be more exposed to these companies or else there is a risk that we get stuck in startup companies and I don´t think that´s enough even if many of them grow. This might not have much to do with the future of the Rails developer, they can switch to something else that is better, or more established on the market. 

But as usual, I might be wrong, it happens :-)
  

 

 

Lets share your thoughts...

 

Thank You,

Uma Mahesh.

 

 

Deploying static website on Heroku.

Hi,

Some times we may have static page website with three to four html pages. We can use heroku for deploying static websites also.

Heroku uses Rack app for this.

Here are the steps that need to be taken for creating the static website in heroku.

Your folder should be organised like this:

- MyApp
  |- config.ru
  |- public
    |- index.html
    |- stylesheets
    |- images


In config.ru file add the following:

use Rack::Static,
  :urls => ["/stylesheets", "/images"],
  :root => "public"

run lambda { |env|
  [
    200,
    {
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    },
    File.open('public/index.html', File::RDONLY)
  ]
}


And there you go, a static site being served on Heroku completely cached and easily served using a single dyno.

To know more information about this check the heroku website: https://devcenter.heroku.com/articles/static-sites-on-heroku

Thank You,
Uma Mahesh.

writing story for a ruby on rails application

Hi Developers,

Before starting any application we need to write user stories as the part for BDD development.

Depending on the way you write the user stories, You will have the outcome of the application and itself shows does your application was healthy product or unhealthy product. So be clear while writing the user stories.

I have seen a blog where they have shown the difference between healthy code and unhealthy code and the things that neede to be taken care while writing the stories.

Here is the url : http://blog.hashrocket.com/posts/writing-the-story-of-an-application

Opensource project management in ruby on rails


Opensource project management.

I have recently heard about the new open source project management too in rails. If any one worked on it, please share your experience and suggestions on using it.

ChiliProject is a web based open source project management system.

It provides a good interface for managing the complete project life cycle.

The official website for chilliproject https://www.chiliproject.org/

Download Chilliproject : https://www.chiliproject.org/projects/chiliproject/wiki/Download

Thank You,
Uma Mahesh.