You must have encountered this error, while connecting to github after you have generated the ssh keys.Some key points to check for this error.- Check the content of the id_rsa.pub file in your system, that should match with the ssh keys in your github account. Copy the content of the id_rsa.pub file and paste it your github account settings page. https://github.com/account/ssh
- If still not working, check whether the port 22 is opened/blocked from your system, as that was the issue in my case, it was blocked.
- Check status of port in Windows
- Open the port 22, if its blocked. Use the command : netsh firewall add portopening TCP 22 SSH enable subnet. Refer here for details about configuring Windows firewall.
- If still not working, generate new ssh keys.
- Try cloning from git, it should work :)
I am working on a rails 3.1 app and lately was trying to depoy the code in Heroku. Heroku has excellent tutorials for the same, but you can encounter some issues which are out of the scope to predict that, for Heroku or anyone as it lies with your system. Same was the case with my system. I am trying to enlist such issues...don't give up hope I know there are plethora of others..try googling them or adding them here in the comments :)
- Fatal error, port 22 can't connect to the mentioned url: The error is caused as port 22 of your machine is blocked. You maybe behind a firewall or using a secure connection (like vpn) to connect to the network. Please disconnect vpn to connect to heroku or check your firewall settings and even if that doesn't work ask the infrastructure team to unblock the port 22. This may appear while pushing your changes to github repository too.
- permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end: I found the solution from stack overflow. It is not able to find the keys in heroku, try uploading those to the Heroku site using the following command from the application directory from the command prompt. heroku keys:add ~/.ssh/id_rsa.pub
- Assets are not precompiled : Either you can refer to the Heroku site or execute the steps in sequence.
(i) Add a production block in the database.yml
(ii) precompile the assets in your local with the following command RAILS_ENV = production rake assets:precompile
(iii) git add public/assets
(iv) git commit -m " pre complied assets"
(v) git push heroku master - [remote rejected] master -> master (pre-receive hook declined) error: This usually occurs after you have added a new gem and trying to push the Gemfile without the Gemfile.lock being updated. The best way is to remove the Gemfile.lock,
(i) rm rf Gemfile.lock from the app dir
(ii) bundle install (this will create a new gemfile.lock)
(iii) git add . (iv) git commit -m "bundle" (v) git push heroku master
Refer to this stack overflow issue for details. - Unable to install pg(posgre) gem in ubuntu: To install pg gem in ubuntu, apart from adding the gem in the bundler you need to first install the package for installation of the native extensions and the dependencies for the pg gem.
(i) From the root directory in ubuntu, install the package with this command
$ sudo apt-get install libpq-dev
(ii) Add the pg gem in your Gemfile.
(iii) bundle
(iv) git add .
(v) git commit -m "added pg gem for heroku deployment"
(vi) git push heroku master Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: To precompile assets and make them working in production(heroku url), add the assets to precompiled as string in production.rb file.
(i) config.asset.precompile = %w(styles.css example.js)
(ii) config.asset.precompile = true
I am working in a rails 3.1 app. My Gemfile is not having any json gem version specified, still one of the gem is having a dependency in json, which was resulting in the error above, I have tried
But neither of them worked in windows. Then I started my app in
VMware+ubuntu and it worked like miracle. So it's a windows issue try installing ubuntu with a virtual machine in your windows and start a hassle free coding in rails :)
When you have unpacked/localised a gem for an earlier version of rails (before rails 3 and the concept of bundler came in vogue), the specification file under the vendor/gems folder might be missing which gives the error in the title of the post. Don't have to panic, you can easily generate a specification file for the same.
Go to the gem directory under the vendor/gems/ folder
- cd vendor/gems/factory_girl_rails-1.0.1
- gem specification factory_girl_rails > .specification [Don't specify the gem version while generating the specification file].
- Or if you have to mention the version use the syntax below
gem specification factory_girl_rails -v 1.0.1 > .specification
Lately I have started using VMware with ubuntu on my Windows machine for faster and hassle free Ruby on Rails development. But nothing comes easy, there are pretty many things you need to take care of for this setup. You can follow the steps
here, preferably sequentially for the installation.
And I would love to add the things which I have faced while installation, setup and while running my RoR app here :)
- wired connection error, unable to connect to INTERNET from the Virtual Machine. Mainly this is caused not only due to your internet connection/ speed but by a corrupted Virtual machine. refer here for detail.
- ERROR: Error running '/usr/bin/make install', please read /usr/share/ruby-rvm/log/zlib/make.install.log. This is mainly caused as you are not executing the commands from the administrator mode. In order to do that, instead of doing $ rvm pkg install zlib do $sudo rvm package install zlib.
- Nokogiri / ruby gems with native C extension failure. Refer nokogiri site for details or follow the below commands for Ubuntu.
Ubuntu doesn’t come with the Ruby development packages that are required for building gems with C extensions.Following are the commands for that. # ruby developer packages
sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
- Invalid gemspec:: invalid date format in specification: error. For any of kind of such error you need to manually edit all the gemspec files which have this error. Look here for details. Otherwise simple change the date format to this s.date = %q{2011-08-31} . For changing the file you may need the root permission, i.e $ sudo vi /path/filename.gemspec will open the file in read-write mode.
- Mysql: sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql
- How to add mysql database related stuff : [[ -s "/usr/share/ruby-rvm/scripts/rvm" ]] && source "/usr/share/ruby-rvm/scripts/rvm"
Remember to add the above lines in the .bashrc file. You can get the file from the root dir (in the terminal type cd..to go to your root dir), just type sudo vi ~/.bashrc [for editing the file as a root user]- How can I share folders/files in VMware: It is as simple as the screenshots below. But remember to have the VMware tools installed, which comes as default in the latest version though :)


I am recently using VMware with ubuntu for my Ruby on Rails developmental purposes for it's faster. But lately I have faced a weird error after all the initial installations went fine. Whenever I was trying to connect to internet it was failing.
I tries to trouble shoot a lot, ping-ing my host server, fixing the ip related files, reloading the VM updates, running the vm-config-ip tools and many other things from the online forums.
Alas!! nothing worked.
Then I re-installed the Vm-ware and created a new virtual machine and realised re-installation was not required.
Whenever you face such an issue, try creating a new virtual machine.
You can delete the older one, as it takes a lot of space is you are using the softwares related to ruby0rvm, git, packages, gems and IDE, etc. All the virtual machines sre stored under the /Documents/ folder by default. You can just go ther and simple shift+delete the folder from there, which you are not using.
Check the new virtual machine IP connection by pinging the host server.
Installing rbx-require-relative (0.0.5) Unfortunately, a fatal error has occurred.
Please report this error to the Bundler issue tracker at https://github.com/carlhuda/
bundler/issues so that we can fix it. Thanks!/Users/sjain/.rvm/rubies/ruby-1.9.2-p290/
lib/ruby/site_ruby/1.9.1/rubygems/ installer.rb:364:in `ensure_required_ruby_version_met':
rbx-require-relative requires Ruby version ~> 1.8.7. (Gem::InstallError)
This happens because when we are adding a dependency on ruby-debug gem in your Gemfile.
With ruby 1.9, you need to update this with new gem name ruby-debug19.
This will eliminate the dependency on rbx-require-relative and fix the issue.
Haml is a much cleaner way to write ruby executable with html. Unlike erb or rhtml, you need not have to give
tags for every if/for loops, no need of <> tags, only remember haml works in indentations. You need to give 2 spaces of indentations under the main loop.
Like for example, you are looping through each element in an array, then for the code which goes inside the loop will look like this
-['a', 'b'].each do |letter|
= letter
- gem install haml
- or in bundler, add gem 'haml'
- make a file inside the view/ directory with extension as .haml.html
remember haml works with indentation. 2 spaces - - has to be added for ruby code which has not to be evaluated <% %>, like for, if, else
- = for ruby code which has to be evaluated, similar to <%= %>
- % for html tags, like th, td, h1 etc.
- no tags are required in haml
%h1
doelThe above two lines will create a html page, with headers as doel.
for label tag in html, in haml label will come under p tag
- form_for @user do |f|
%div
%p
= f.text_field :name
User nameAnd if you have all your codes in html.erb and would lke to convert that to Haml very quickly, you can try out the below link, it's easy :)
http://html2haml.heroku.com/But remember to test your app with the new haml before pushing the changes..
...coming soon more and more on happy Haml
I faced the weird error coming up suddenly for my rails 3 app using ruby 1.9.2 using pik
the rake.gemspec file under the ruby gems folder getting some issues.
remove the rake.gemspec file
do a fresh bundle install for your application.
need not have to specify the rake version in your gemfile, as ruby 1.9.2 takes care of it.
This is one of most common error, you will find when you start working with rails3. But the solution is really simple. Just change the gemname to mysql2 instead mysql in the Gemfile. By now we know, that Gemfile is like a repository of the gems we need for the application, somewhat like unpacking a gem, so that we do not need to install manually the huge list of gems in each environment and bite our nails if we miss something.
The entry in Gemfile is something like this,
gem 'mysql2'
from the command propmt, go to the directory where your app is, and execute the following command to install all the gems in gemfile
bundle install
That;s it your gem mysql2 has been installed.
Now you need to change the database.yml adapter from mysql to mysql2.
run rake db:create
and see your app up and running in http://localhost:3000 (ofcourse you need to start the server , if not started yet ;)
rails server
Happy Rails-ing :)
Lately I am trying to get hold of version control tool git. I have worked with svn but git has whole of other options and believe me it is not so bad as your first impression if you are an svn user. First Impression is not the last impression, always. Actually this is not the first, as we need to unlearn certain things which sometimes makes it tough. Got hold of the below link in case you use both, like me and often get confuse with the syntax.
http://git.or.cz/course/svn.html
- Download git on windows from http://code.google.com/p/msysgit/downloads/
- Use git
- Ssh-keygen –t rsa –C hello@gmail.com
- git config --global user.email hello@gmail.com
- git config --global user.name “Hi Hello“
- git config --global github.user hi-hello
- git config --global github.token 0987654321yourf0123456789
For some advanced concepts in gitMigrate from svn to git
Do a SVN Export of the repository you want to migrate to GIT.
• Goto the Directory
• git init
• git add .
• git commit –m ‘Migration from SVN to GIT’
• git remote add origin git@repository_location.com
• git push origin master
Git Stash
Very often while committing or pushing or pulling our changes in/from remote repository, we get the error message, like "you have local changes, please stash your changes or remove them before pushing". Now that means the local changes are nor allowing them to pull the things (sometimes wither you will have a conflict which you can edit later ) or the stash them. Now what does 'stash' means in git, same as the dictionary meaning To hide or store away in a secret place.
Commands
• git stash save “your message for the stash” --> This command will save your changes away to the stash, and reset your working tree and the index to match the tip of your current branch.
• git stash list --> you can see which stashes you have saved
• git stash pop --> you like to pop out the last stash, similar to pop out an element from a linked-list.
• git stash apply stash@{0} -->you can go back to what you were working on with git stash apply: stash@{0} part? That's your stash ID. The stash ID changes with every stash you make. stash@{0} refers to the last stash you made.
• git stash show -p | git apply –reverse
•
• git stash clear --> you like to clear out all the stashes.
References:
For using git with Windows this link is really useful :
http://nathanj.github.com/gitguide/tour.html
enjoy !!
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
oci8.c:270:in oci8lib.so
I encountered this problem in my local machine while I an trying to start a Ruby on Rails application using oracleXE as a database. Check first whether the oracle XE service was running. If not do the following.
In order to start the service
--> goto Contol Panel
--> Administrative Tools
--> start OracleSevice XE
That's it...type local:3000/ to see your app up and running !!
I am following Paulo Coelho's blog these days.
It has a refreshing section named 20 sec reading...was lured by the name itself, it can be possible by an author of his stature only to write such an interesting and intriguing post which can be read in time as short as 20 secs. Like to recommend to read his blog and refresh the mind.
http://paulocoelhoblog.com
Watched the awesome movie 'Goal' (English). The protagonist Santiago Munez inspires all to chase a dream and I am no exception. The young boy suffered from asthma and tried of hiding that, fearing he may loose the chance to play in one of the premium football teams. When the selector came to know of this fact, quite contrary to my expectation of a person in such a situation he told, "Asthma is not a problem, but lying is!". What a thought, and what a way of expressing that. Many a times I keep on thinking the different physical criteria which are necessary for applying for job of our dream, such as in army, air force, ballet dancer or a soccer player.But rare do we listen such a noble thought of handling our physical problems and to deal with it medically rather hiding it.
Similar to working in a team, be it in our school project to make a poster or to finish up the lab assignments in the college days to our present official deadlines, we need to "Pass the ball" in the soccer field. We need to learn that the ball runs faster and the more effectively we can delegate/distribute the work, the effective will be the ball in reaching the goal-post. It remind us that to work in a team, the work is more important than the worker, hence it has been aptly said, the team's name in jersey is written in front and the player's in the back.
Though Santiago's father was against his dream of becoming a footballer but at the end he was also convinced by his passion. Though he passed away and may not be physically present to witness him playing but he was seeing that from above. Whatever grief we may face in our life, which is not in our hands, we may learn to think that life and death are not in our hands and we may learn to live life with realising the eternal truth and "All in our life is not in our hands."
1)To list all files
ls
2)To list files with file size
ls -lh
3)To go to the end of file
tail -f /root/
4)To edit/create a crontab
crontab -e
5)If the cron job is in different directory add the following in the shell script which
the cron calls
PATH
LD_LIBRARY_PATH
6)To go to the top/end of a long file, type the following while the file is open
1G
7)To change read/write/execute permission of the file
chmod
8)To call website from linux OS
curl`http://abc.com`
9)In shell scripts there should be no spaces between variables and = sign
10)To replace a word, go to the beginning of the word and type
CW
11)To delete a line, press
ESC-key+X
12) If you have the vim editor installed, can try out the following
dd --> to delete a line
yy --> to copy a line
p --> to paste the above
Shift6 --> to go to the beginning of a line
$ --> to go to the end of file
I confronted the error whenever I was trying to run, for my new rails 3.0 app in Windows 7
>> rake cucumber
The error looked like
>>uninitialized constant Win32 (NameError)
Solved by installing the following gem, adding the line in the gemfile
gem 'win32console'
Go to your app directory and execute >> bundle
That's it !! I am able to run the cucmber now :-)
Got the above error whenever I was executing rake for my new rails 3.0.0 app in Windows 7.
Comment out the following lines from the rbreadline.rb file under C:\Ruby187\lib\ruby\site_ruby\1.8
This is really a huge file, opening in Word and then adding line numbers in the document may help you in commenting line number 4404. Though it may sound silly but I am adding the steps to add the line numbers in word document too.
File -> Page Setup -> Layouts -> Click on line numbers --> continuous
Line no 4404
and the following one
if defined? ''.getbyte
@encoding = "X" # ruby 1.9.x or greater
# @encoding_name = Encoding.default_external.to_s
end
For details the following URLs are really helpful
http://trbhoang.blogspot.com/2010/05/issue-with-rspec-on-windows.html
http://tom.net.nz/2010/09/installing-diaspora-on-windows/
A couple of days back I have installed Ruby 1.8.7 for working with Rails3.0.0 To my surprise whenever I was executing the any of the gem installation commands with native extensions, it was failing. Then I found the following stuff after searching quite a bit.
Following URL gives the details or else you can look at the bullet-ed points below and execute them in order
1) Uninstall any DevKit previously installed in your system. Control Panel\All Control Panel Items\Programs and Features --> uninstall Devkit
2) Get the DevKit from the following url http://rubyinstaller.org/downloads/
3) Download the exe file to a local folder like D:/DevKit
4) Go inside the folder from the command prompt and execute the following commands
i) ruby dk.rb init --> this will create the config.yml file
ii) ruby dk.rb install
iii) devkitvars.bat --->; This will add in the PATH variable
5) Install the gems
gem install devise --platform=ruby
gem install devise_rpx_connectable --platform=ruby
6) or you can add them in the Gemfile of your rails3 app and just execute
bundle
The above command will then install the gem with the native extensions. Remember to add the platform part.
There was queer habit of mine to store the things for the perfect time.
A simple, incident describing this. It was in our school days, when the sachet concept was not in vogue like these days. I got a free sachet of Rasna(a fruit drink, in powder form) from our local grocery shop. I was so excited that I kept it for a long period of time. Each day, when I return from school, I would have seen the sachet on our center-table in the drawing room and thought , I would have it when I would be more tired and thirsty .
Couple of days passed and suddenly on a day I find that sachet no more on it's place.
I searched the entire place, from the pile of newspapers, our telephone diaries (we don't use to have contacts in our cell phone to store the numbers during that time).
Alas! it was not there.
My Brother returned home, and to my surprise he asked me the place from where I got that Rasna sachet? He had it, few days back!!!
My Learning:- Don't wait for the ideal and the perfect situation, whatever and wherever you are you can make it perfect.
The tall trees moving vehemently with the strong winds, thunderstorms crackling through the dark, deep sky like millions of diamonds in a systematic unsymmetrical line. I stood awestruck on the beach, the waves splashing against my feet and left behind the curious feeling of the wet sands in between the fingers while they retreated back to meet the sea again. What a feeling may Lord! I sighed, inhaled all the breeze, the air travelling all across the finest of alveolli spread across my entire being.
Lets welcome the life, lets breath the happiness, lets cry for the joy within.
Ratan Tata is the chairman of Indian Hotels who own the Taj Mahal Hotel Mumbai, which was the target of the terrorists on 26/11/08.
Hotel President a 5 star property also belongs to Indian Hotels.
The following is really touching.
What Ratan Tata did for the Mumbai victims.... Don't miss!!!!!!
SALUTE TO MR. RATAN TATA
A. The Tata Gesture
1. All category of employees including those who had completed even 1 day as casuals were treated on duty during the time the hotel was closed.
2. Relief and assistance to all those who were injured and killed
3. The relief and assistance was extended to all those who died at the railway station, surroundings including the "Pav- Bha ji" vendor and the pan shop owners.
4. During the time the hotel was closed, the salaries were sent by money order.
5. A psychiatric cell was established in collaboration with Tata Institute of Social Sciences to counsel those who needed such help.
6. The thoughts and anxieties going on people’s mind was constantly tracked and where needed psychological help provided.
7. Employee outreach centers were opened where all help, food, water, sanitation, first aid and counseling was provided. 1600 employees were covered by this facility.
8. Every employee was assigned to one mentor and it was that person’s responsibility to act as a "single window" clearance for any help that the person required.
9. Ratan Tata personally visited the families of all the 80 employees who in some manner – either through injury or getting killed – were affected.
10. The dependents of the employees were flown from outside Mumbai to Mumbai and taken care off in terms of ensuring mental assurance and peace. They were all accommodated in Hotel President for 3 weeks.
11. Ratan Tata himself asked the families and dependents – as to what they wanted him to do.
12. In a record time of 20 days, a new trust was created by the Tatas for the purpose of relief of employees.
13. What is unique is that even the other people, the railway employees, the police staff, the pedestrians who had nothing to do with Tatas were covered by compensation. Each one of them was provided subsistence allowance of Rs. 10K per month for all these people for 6 months.
14. A 4 year old granddaughter of a vendor got 4 bullets in her and only one was removed in the Government hospital. She was taken to Bombay hospital and several lacs were spent by the Tatas on her to fully recover her.
15. New hand carts were provided to several vendors who lost their carts.
16. Tata will take responsibility of life education of 46 children of the victims of the terror.
17. This was the most trying period in the life of the organization. Senior managers including Ratan Tata were visiting funeral to funeral over the 3 days that were most horrible.
18. The settlement for every deceased member ranged from Rs. 36 to 85 lacs [One lakh rupees tranlates to approx 2200 US $ ] in addition to the following benefits:
a. Full last salary for life for the family and dependents;
b. Complete responsibility of education of children and dependents – anywhere in the world.
c. Full Medical facility for the whole family and dependents for rest of their life.
d. All loans and advances were waived off – irrespective of the amount.
e. Counselor for life for each person
B. Epilogue
1. How was such passion created among the employees? How and why did they behave the way they did?
2. The organization is clear that it is not something that someone can take credit for. It is not some training and development that created such behaviour. If someone suggests that – everyone laughs
3. It has to do with the DNA of the organization, with the way Tata culture exists and above all with the situation that prevailed that time. The organization has always been telling that customers and guests are #1 priority
4. The hotel business was started by Jamshedji Tata when he was insulted in one of the British hotels and not allowed to stay there.
5. He created several institutions which later became icons of progress, culture and modernity. IISc is one such institute. He was told by the rulers that time that he can acquire land for IISc to the extent he could fence the same. He could afford fencing only 400 acres.
6. When the HR function hesitatingly made a very rich proposal to Ratan – he said – do you think we are doing enough?
7. The whole approach was that the organization would spend several hundred crore in re-building the property – why not spend equally on the employees who gave their life?
Hats Off to Mr. Ratan Tata..
[Source: From FB Suresh post]
Great Egyptian Pharaoh Tutankhamen, may have died due to brittle bones caused by malaria.Read an interesting news regarding the death mystery of the young pharaoh Tutenkhamen.
http://news.bbc.co.uk/2/hi/health/8516425.stm
Some of the best learnings which I learned in this year.
The first two are learnt from the awesome one-act play by the great Indian artist Anupam Kher, named "Kuch Bhi Ho Sakta Hein" screened on 3rd January 2010, in NCPA, Nariman Point, Mumbai.
1) Don't go over your worry twice! once by thinking of it, and once by going through it!
This has been told to Anupam Kher by his grandfather.
2) If you take risk you may get failure, if you don't then you ensure it!
Though the word "best" attributes to a single thing but still it can be pointed out that learning whenever and wherever they are , they are always the "best".
3)The cumulative effect of all the organisms that we touch upon in our lives makes us what we are (as stated by Mr. Sudhakar, Tata Chemicals), in one of the seminars I attended lately.
4) Leaders have the capability to treat others with equality and humanity. Such an impeccable flavour of leadership without the heavy hearted words giving us the feeling of domination, perfectionism, authoritarian is rarely to be found in anybodies definition of leadership.