Some useful notes on rails 3.1

Here I’ll try to list some useful things that I faced while developing a rails app as a noob.

Ok let’s say you detached your rails server to use the same terminal, but later you need to stop rails server, how? (surprise!)

The solution I found is simply finding Webrick server process id and kill it!

ps -ef | grep script/rails

now, kill the process id which is the first integer on the line

———————-

If you follow a “rails 3 tutorial” just like me, you probably have problems with ajax.

That’s because now jquery is default js framework in 3.1, not prototype. Prototype is a gem which you need to add your Gemfile to use that.

That’s why you should write partial templates in a .erb file not .rjs

An example change:
page.replace_html(‘item’, render(@item))

$(‘#item-holder’).html(“<%= j render @itemĀ  %> “);

———————-

And lastly, If you installed MAMP and using MySql for your rails app, that’s a good chance that you will have issues while connecting the DB.
Below is my database.yml which works for me for a rails 3.1 app

adapter: mysql2
host: localhost
database: railsapp-dev
username: mamp_username
password: mamp_pass
socket: /Applications/MAMP/tmp/mysql/mysql.sock

———————-

That’s all for now, probably more rails posts will appear here..

 

Tags: , , ,

Comments

No comments so far.

  • Leave a Reply
     
    Your gravatar
    Your Name