Friday, September 28, 2012

General ruby on rails installation and integrating issues

Error integrating mysql withRuby on rails

Invalid date format specification error :
"gem install rubygems-update", "update_rubygems", then "gem pristine --all" is the combination that solved the problem for me

Deactivate a Gem - you have already activated rake 0.9.3.beta.1, but my Gemfile requires rake 0.9.2
run command: "gem uninstall rake" then command prompt will ask you which version to uninstall and selet 0.9.3 there after you will be left with the desired rake version.

Saturday, September 22, 2012

Semi Join and AntiSemiJoin, SQL

Joins explained :

Monday, September 17, 2012

missing :controller ( ArgumentError), Ruby

C:\work\BackChannel>rails destroy Category
/routing/mapper.rb:179:in `default_controller_and_action': missing :controller (
        from C:/work/BackChannel/builder/ruby/1.9.1/gems/actionpack-3.2.1/lib/ac
tion_dispatch/routing/mapper.rb:76:in `normalize_options!'
        from C:/work/BackChannel/builder/ruby/1.9.1/gems/actionpack-3.2.1/lib/ac
tion_dispatch/routing/mapper.rb:59:in `initialize'
        from C:/work/BackChannel/builder/ruby/1.9.1/gems/actionpack-3.2.1/lib/ac
tion_dispatch/routing/mapper.rb:1302:in `new'

I was having this error while running either a destroy command or scaffold to create new category. Later I realized it was because of some existing routes present in routes for Category model. After removing them command worked successfully. In order to debug such error track the stacktrace of error and find any file which is part of your project. I mean not the ruby code base file.

Delete controller, view, models automatically from Rails Application

In Ruby on Rails, it is quite easy to create a new model view and controller using the scaffold command. Apart from the mentioned MVC this command also creates many other files like migration which proves quite helpful for creating a new ruby application.

However there are times when you want to delete a controller / view / model from the application along with files that are automatically created with the scaffold / generate command like fixture, spec etc and the simple command to ease your task is destroy (Rails3). Use it like

rails destroy controller controller_name
e.g. rails destroy controller categories

Here we can replace controller with view or model to delete an appropriate object.

Note that while specifying controller name just specify the name of controller not controller file name like here categories not categories_controller.rb. This command will delete categories controller, model, view and other background stuff. Here is the list of task done by the command fired in example.

Saturday, September 8, 2012

Installing a fresh copy of Latex and editor on windows machine

If you need to create a document with lots of mathematical functions then it is very well suggested to use software like Latex. Basically Latex in itself is not an editor however it provides binaries/libraries which can be used by a text editor for creating highly sophisticated documents full of Greek alphabets.

Follow following simple steps to install the Miktex and TexnicCenter
1. Download MikTex latest version from this page MikTex Setup.
2. Install it and mind it while installing, setup will prompt you when to download additional package which is default to 'AskMe' change it to Yes so that you've all updated and required binaries. It might be possible that if you don't change it you won't get Tex.exe or Latex.exe which are required for an editor.
3. Next, download the text editor for creation of your text document using Latex. I personally prefer TexnicCenter, download its latest installer from this link Texnic Center Setup (In case link is not working use this link instead Texnic Download Page)
4. After download and installation of TexnicCenter, when you run the TexNic Center first time it will ask for several configuration which are very important for proper working of software.

a) Link to Latex.exe or Tex.exe distributables. Supposing you're using a 64 bit machine, provide this link C:\Program Files (x86)\MiKTeX 2.9\miktex\bin and press next.
It might be possible that here dialog will prompt with error: "The application latex has not beed found in the directory of your tex distribution". This error comes because you did not change the automatic libraries download option for MikTex from 'Ask Me' to 'Yes', which I mentioned in step 2. Simple resolution will be to repeat step 2 only. I personally stuck on this step for atleast 2 hours.

b) If you are good with latex link then next setup will ask for post script viewer path which is basically a software where you wish to view your document after compiling through latex. Generally it is Adobe reader so provide the link to adobe reader.exe.
On my machine link is:
C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRD32.exe

If nothing strange come up then you're good to go. Open Texniccenter to create new latex documents. After writing documents you first need to compile your documents (F7) and view output (F5).

This is my personal experience with latex installation. It might be possible that something new come up so please feel free to post your issues and suggestions.