stupid google -->

Wednesday, May 31, 2006

FC5 Pirut Package Manager

Mag wrote a nice tutorial here =) enjoy...

http://opensourceatwork.blogspot.com/2006/05/fedora-core-5-pirut-software-package.html

oh and ya know what is freaky?

She did it by herself but it was so similar to this one :

http://arindamlahiri.blogspot.com/2006_05_01_arindamlahiri_archive.html


Mag's one is more detailed though =P

Sunday, May 21, 2006

Ruby On Rails

Ruby on Rails

This is my blog on Ruby on Rails


log 1 - 060503 - 9:36 am
+++++++++++++++++++++++++++++++++++++++++++++

Currently I have just installed Ruby on Rails... it was quite a pain ;)

bad timing I guess.

My machine:
512 ram
HP compaq tc1100 tablet
(looks like the one Angelina Jolin used in Mr and Mrs Smith =P)

Versions I used:

Ruby: 1.8.4.rc1
RubyGem: 0.8.11

Details can be found here:
http://www.rubyonrails.org/down

do note that the site recommends 1.8.4 but the link is to 1.8.2

If you use 1.8.2, rubygem will hang when it tries to update the source index.

I could not find any solution to it (as in code patches or configurations, arcane commands and the like ;P but uninstalling 1.8.2 and installing 1.8.4 seems to work)

of course these things change so damn fast, the date today is 060503

things may have changed by the time you read this of course =)

[part of the fun in open source is solving the bugs =P]


I will probably just keep editing this post to keep things sane =P


With 1.8.4 installation is a gem! lol


Still on the same site (i.e. setting up rails)...


some oddities you should note (esp if you are a windows addict like me)

the site says:
rails path/to/your/new/application

the next line goes:
cd path/to/your/new/application

now... this is windows and you ARE using the cd command so its '\'


When you run the ruby rails server, windows firewall may complain, just "unblock"


-----------------------------

This was a GODSEND!




********************************************************

[Rails] Connection refused on new install--Not Question

Ray Dai raydai at gmail.com
Thu Dec 15 06:51:15 GMT 2005
Downloaded/installed Ruby on Rails 1.0 on Windows,
rails path/to/your/new/application
cd path/to/your/new/application
ruby script/server
and tried to access it on http://0.0.0.0:3000, got connection refused
error in firefox.

tried again using
ruby script/server -b 127.0.0.5
and it worked just fine, the url is now:
http://127.0.0.5:3000/

For some reason, my machine don't like 0.0.0.0 The -b switch allows you
to pick a different IP and that worked.

Hope this helps someone.
Ray

--
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list

from:
http://lists.rubyonrails.org/pipermail/rails/2005-December/005336.html


********************************************************


Replace the original site's command with this:

ruby script/server -b 127.0.0.5

using the site's original code (
ruby script/server)

0.0.0.0:3000 - I got connection refused whether with Firefox or IE.





filed as: rubydocs060721.txt

Ruby on rails:


Three pieces of codes are important:


1. rails mainName

2. ruby script\generate model modelName
3. ruby script\generate controller modelName




Running 1. creates the main folder, from then on, run 2

and 3 in that folder.


Running 2 creates the necessary folders for the model,

this is akin to classes in Java. There are quite a few

built in functions (such as validation)

Running 3. creates the controller files. note that

controller handles "actions"


Between the views and controllers there is an

interesting/convenient relationship.

every action in the controllers must have a matching

.rhtml file or a "template not found error" will be

thrown.

on creating the xxx.rhtml (for example if your controller

has a "def xxx"), the next time you go say

localhost:3000/blah/xxx, it will display the xxx.rhtml

file.


note that if in def xxx you have render_text "blah", it

will override the xxx.rhtml file, i.e. you will not see

it. also note that render_text has been deprecated.


So far i have achieved linkage between rhtmls but data

access has been problem matic.

I have found out how to get the scaffolding.

essentially you just need to great a table with the plural

of the model name and in the model_name_controller.rb file

edit it so that it has for example:


--------------------------------------------------
class CustomerController < ApplicationController

scaffold :customer


end

--------------------------------------------------



once you have this ntyping

localhost:3000/blah/customer

will by default give you a listing of the associated

database.


In this case, customers.


The problem here is that I cannot see the list.rhtml in

apps/views/customer

I believe this to be a bug, as most of my search on the

web actually shows that the list.rhtml exists.

Moreover, if I write a blank file called list.rhtml into

apps/views/customer, when I type

localhost:3000/blah/customer, I actually get a blank page.

Indicating that the file had over written something in

memory.

However if I delete the blank file, i cannot get back the

list.rhtml view. I can restore it however by restarting

the server.

i.e.

go to the root of the rubyonrails app folder and type

"crtl C" then ruby script/server


Its really weird.


One alternative is to use this command:

ruby script/generate scaffold Product Admin


where Product is the name of the model for which you which

to build the scaffold and Admin is th ename of the

controller for the model.

You can then use the Admin controller to manage the

models.


you could similarly create


ruby script/generate scaffold customer

which is the model I am using.

But it generates customers, instead.

All in all i have given up trying to use the scaffold,

opting for the more direct way of database access then

data manipulation.

THis seems to be shown in the Agile Web Development with

Rails page 64.


But I think I have to read more resources and maybe brush

up on my ruby.


!!!

[update - 060723]
ruby for windows can be downloaded here
[/update - 060723]




[update - 060726]
now the command for generating models is:

>> ruby script\generate model modelName

>> ruby script\generate controller modelName


command for generating a scaffold is:

>>ruby script/generate scaffold modelname controllerName



strictly speaking you need to leave out the "controller" portion when you use the command.

so an example could be

>> ruby script/generate scaffold boo boo


this command will actually generate a boo_controller

The scaffold is good for learning how the database access and paging works.


I did two scaffolds.

one for a model called main another was for a model called customer (yes my previous one)


What I realised to my consternation was that I could not call the action of another controller.

It was somewhat disappointing.


However that got me to messing with my controller and .rhtml files.


I wonder if ROR has tags to make certain divs invisible....



I know asp.net can.




It was really odd, I put some of the codes from the main_controller into the customer_controller and some of the main.rhtml into the customer.rhtml....


this got me running 2 tables.. most odd =)

Oh and I realised the pagination is global.. but how many each shows on a page is dependent on its own marker... =)


Although I cannot conceivably understand why I would want to do that...



[/update - 060726]


[update - 060727]
a few things I have learnt today:


creating a partial portion of a page.

this is the tag that does it:

<%= render :partial => 'form' %>


the 'form' is the in reference to a .rhtml in the views

folder.

to denote such folders, I suspect you need to add an under

score to the from of the name of the .rhtml

for e.g. the 'form' refers to the _form.rhtml file



----------------------------------


Another discovery, having underscores as column names in

mySQL screws up ROR


for example:

if the column names for a table are:

ID, Subject, Reply_to, Text, Topic_ID


Topic_ID will not bw printed when you use the list scaffold

code,

also Reply_to is printed as "Reply to"


This bug, took some time... good lord....



Good advice on passing parameters
[/update - 060727]
This is the first post for the huffalump project...


ermm yah


I'm just reorganising my blogs, I like huffalumps so there =)


Anyways this is my tech blog, I will be updating this with mostly technical stuff. I also Have stuff on magic the gathering, the rest is just miscellaneous stuff =)
-->
Clear | Activate AJAX Google Search | |
Firefox 2
Support Wikipedia