Wednesday, February 24, 2010

Rails - select class not applied

Hi, previously my code was like this, I tried much using, html_options, options, but class is not applied for select.

<%= 'difficulty', options_for_select({ "Easy" => "1", "Medium" => "3", "Hard" => "5"}, get_difficulty(@tour).to_s), :class =>'input_text' %>
Right way to do:
<%= select :tour, :difficulty, { "Easy" => "1", "Medium" => "3", "Hard" => "5"}, {:selected=>get_difficulty(@tour).to_s}, :class=>"input_text" %>

Now class is applied!!!

Any other better way pls tel me,,.</span>

Tuesday, February 9, 2010

Getting a MySQL DB dump in local machine from server

Getting a DB dump in local machine from server..

Step1: Login into the server where mysql is hosted -
ssh username@server
Step 2: Take MySQL Dump
mysqldump dbname -u dbusername -p > filename.sql
Step 3: Logout
Logout of server
Step 4: from Local machine
scp username@server:server_path/filename.sql dumpfile.sql

The above steps can be done in 1 step.
mysqldump -h hostname -u dbusername -p dbname > filename.sql

Monday, February 1, 2010

You’re in the middle of a conflicted merge (git)

Trying to update (pull) in git causes the error ‘you’re in the middle of a conflicted merge’.

How to resolve a Git Conflict? 

NOTE: Take a backup of your code before you do this. This will remove all your changes and revert to master branch!!

To be able to get out of this error try the followng:

  1. git reset --hard HEAD
  2. git fetch origin
  3. git reset --hard origin
to reset the state, and then you should be able to use git pull as normal.

This site helped me when i faced this problem -