Posted by arjunghosh on December 23, 2008
Model names in RubyOnRails should be Singular. This will create Table name as corresponding Plural names.
You have got to remember that about model naming conventions in rails. .
I know this is a very basic concept in RubyOnRails but sometimes these simple basic concepts are the ones which slip through the cracks.
> ruby script/generate model Post
This will create a Model by the name “Post” i.e. singular in english language and a migration to create a table by the name “Posts” which is plural form of “Post”.
I have even put this into a pastie for easier remembarance http://pastie.org/345491
Posted in Uncategorized | Tagged: activerecord, conventions, model, Newbie, rails, tips | 7 Comments »
Posted by arjunghosh on September 6, 2007
As i mentioned in my previous log on starting WEBrick server manually from command line, here i look into the often asked question about starting Multiple instances of WEBrick server at the same time so that multiple Rails application can be run at the same time.
So continuing from my prev log…
Suppose we have to run another test called “AnotherTestRailsApp” beside “TestRailsApp” already running on our machine.
1. Now type the command
ruby script/server -p3001
“c:\AnotherTestRailsApp> ruby script/server -p9001”
2. Now to also run “AnotherTestRailsApp” rails app can be accessed by going to the address bar of your browser and typing the command at the address bar:
So here the above Rails app “AnotherTestRailsApp” is running on port 3001 instead of default 3000. This number can be any thing like 3010 or 9000.
3. So we now have one rails app “TestRailsApp” running at port 3000 and another “AnotherTestRailsApp” rails app running at port 3001
Posted in Uncategorized | Tagged: Newbie, rails, rubyonrails, server | 4 Comments »
Posted by arjunghosh on September 6, 2007
1. First open the command line window. For windows get there by clicking on start->run
2. The following command will open the DOS command windows. Type the following:
3. Go to the folder which contains the your RoR project using the command:
“c:\> cd TestRailsApp “
4. Now type the command:
“ruby script/server” at “c:\TestRailsApp> ruby script/server”
5. This will start the WEBrick Server for the particular application which in above example is TestRailsApp
6. Now this “TestRailsApp” rails app can be accessed by going to the address bar of your browser and typing “http://localhost:3000/”. This will open the default starting page of your application. Now the question is what is number 3000. Well thats the default port 3000 at which the server is running on and hence the application
Thats all from my recent travel through Rails Galaxy…
Posted in Uncategorized | Tagged: Newbie, rails, rubyonrails, server | Leave a Comment »
Posted by arjunghosh on May 28, 2007
Its been some time but i was doing what i love best – Hitchhiking through the RoR galaxy!!!…and am taking a quick stop right now. And did i discovered? this wonderful tool called RDoc. Well if code and that too well, it all goes down the drain if the next person can not come to know what the hell did you make. Well hence as i said lasts time i stopped – code, code and do more code, well this round – document, document and do create very concise document of your code. You would ask why do i need to…well tomorrow you get bored of your project, you are reassigned, you fall into drain….and some one else come in to continue your work. Well he/she will go bald if there is no doc for the app.
- Firstly, two websites which are of help for RDoc are:-
- RDoc Download. From Here you can download RDoc
- RDoc Documentation and Help
- Kevin has also written a very article on Documentation in Rails. Have a look
- Make sure First and foremost you have downloaded RDoc and installed it. Download it from the site given above.
- Now few easy steps to generate Documents for your application using RDoc are:-
- Open the command line window(dos shell) – if you don’t know…well click on run then type “cmd” and click ok.
- Then change directory and go to the folder where your app resides. For example your app resides at “\depot\”, so go under the “depot” directory using the “c:\ [your application path] cd depot” or something like this. 🙂 you will figure it out.
- Then run the command “rake appdoc” and this generate the HTML documentation of your application and place it under the “\doc\app\” folder.
- You can access it by going to this folder and opening the index file.
- Well thats about it. Now go do it. Document all your rails app. Until next time.
Posted in Uncategorized | Tagged: Newbie | Leave a Comment »
Posted by arjunghosh on May 11, 2007
[Also this place is not a Tutorial nor does it claim to teach RoR here. So don’t be disappointed by it. It just gives leg up for the RoR programmers who have found this new exciting thing and are having a blast exploring and sharing their experiences of the travel in RoR space with others here…;-)]
- Firstly, two fabulous Help websites for Ruby and Rails respectively are:-
- Ruby Help Docs
- Rails API
- A quick Ruby Reference Cheat Sheet…found both helpful :-
- Ruby Quick Ref
- Ruby Syntax
- You will be doing lots and lots of documentation..fear not, RDoc is here…
- One thing for which i burnt midnight oil…but finally did it, is…Multiple File Upload. The Two most helpful sites i found are:-
[NOTE: Multiple File upload can be implemented using various method, all with there different pros and cons. I implemented it using attachment_fu method. Do try the others]
- This help to understand file upload using attachment_fu. This site by Mike has wonderful explanation of this implementation.
- This helps to implement the above for multiple file upload. This guys explains the multiple upload in a nice manner.
- Another place for help with Rails is:-
- Rails Wiki
- Two more things which you probably will be using a lot for managing Projects in your company are:-
- Putty for Remote Server access
- Putty Information
- Tortoise SVN for Project Management
- Tortoise SVN Information
- One more good thing i found on my journey through the RoR space is that i met some awesomely helpful people. This is one one the best thing about RoR is that it has lot of community support and guys take help from them. At first you might feel intimidated but that will pass. After that its a breeze. Join any of theses groups and believe me you will get lot of help. My suggestion is to join the General group first.
- Last but not the least… and recently as my mentor,my boss and (i hope) my friend a.k.a Greg said – “Code not just Read” meaning that for most newbie, the terrifying thing is to start coding…so newbie keep on on and on reading stuff about RoR but forget the actual thing – to code (believe me i have been in that predicament). So my advise (practical one 😉 ) is read some, not much (and this blog can be that starting point) but start coding (and if IDE for ruby is an excuse…try using Scite…atleast i found it good and for Rails try using EasyEclipse) as soon as u can. There is no better method to learn that actual hand on, down and dirty CODING. So happy coding in RoR and travel trough the RoR galaxy and until my next Hitchhike…ciao
Posted in Uncategorized | Tagged: Newbie | 4 Comments »