Tuesday, August 19, 2008

Ruby and Rails installation discussion with rizal

rizal.narayan: I installed aptana
2:35 PM me: cool
rizal.narayan: and mysql
me: cool
rizal.narayan: but I am not able to run the project you sent me
me: ok
rizal.narayan: I imported it to the studio as well
me: did u created table
students
in the database
rizal.narayan: you know I cannot see the mysql database interface in the studio
me: u cant see
2:36 PM i used gui tools
for mysql
rizal.narayan: how to create the table
me: u can try cmd line
rizal.narayan: send me the link for that GUI
me: but u have to install 5.0version of mysql
gui tools for 5.0 version
rizal.narayan: create table students (id primary key, first char(40), last char(40))
2:37 PM me: yeah
rizal.narayan: is this correct
me: thats right
after creating run the select cmd
i think u know all those
rizal.narayan: what was the database name?
2:38 PM me: student
u can create with any name
u want
does not matter
but u have to refer in database.yml file
rizal.narayan: I created the database but how to create table inside that database?
rizal.narayan: what is the data type of ID colum
me: integer
always
2:40 PM rizal.narayan: but how does it auto increment?
me: u have to set up
2:41 PM CREATE TABLE `jagan`.`students` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`first` VARCHAR(45) NOT NULL,
`last` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`)
)
use ur database name in jagan
2:43 PM rut
rizal.narayan: http://dev.mysql.com/downloads/mysql/5.0.html#win32 which one to download from here
2:46 PM rizal.narayan: will this over write the one I have already installed?
me: ha
which version u installed
rizal.narayan: I think 5.0
2:47 PM me: check in cmd line
rizal.narayan: 5.0.67 - community edition
me: yeah
enough
rizal.narayan: but thereis no guy
me: no need to install again
2:48 PM rizal.narayan: how to get the gui?
management studio like thing
me: go to downloads section
rizal.narayan: where?
2:49 PM me: in mysql
.com
2:50 PM use last link
rizal.narayan: from US
me: ur wish
rizal.narayan: ok getting on
me: cool
rizal.narayan: how as the day?
me: did u installed ruby
2:51 PM cool
rizal.narayan: yes
me: gems
rizal.narayan: i loaded you project as well
gems?
me: tell u
2:53 PM (extract, then run "ruby setup.rb")
rizal.narayan: is there any way to check if it is already installed?
me: i know u did not isntall
no pr if u hv old version
2:54 PM there is version checking tooo
rizal.narayan: so I will install again
me: wich ?
rizal.narayan: ruby
me: y
2:55 PM its already there right
rizal.narayan: I have the studio
but do't know if ruby is there or not
me: oh
so install ruby
after that
let me know
after this
2:56 PM u can run cmd line " ruby --version'
rizal.narayan: tell me how to login to the SQL server first
there is stored connection
me: ok
2:57 PM rizal.narayan: what to fill up?
me: after u installl gui tools
rizal.narayan: yes i installed
me: click on query browser
rizal.narayan: ok then
2:58 PM me: prior to that u have to start the server
rizal.narayan: how?
me: check in program files
under mysql serve
look for instance config wizrd
rizal.narayan: no option to start
2:59 PM me: no
u hv to set up the server
just click wht i said
check in program files
under mysql serve
look for instance config wizrd
3:00 PM do u get that /
?
start->programs->mysql->mysql server->instance configure
where set the password as root
3:01 PM just to rememer
3:02 PM rut
?
rizal.narayan: hello
3:03 PM me: wht happend ?
rizal.narayan: I applied
pasword
me: k
after finish
3:04 PM come to query browser
rizal.narayan: tell me what to type in the query browser
ok
me: root
root
schema here is anything
lets say
student
rizal.narayan: ok
me: iif u want u can store the connection
3:05 PM not reuired now
rizal.narayan: what is the server host
me: localhost
its on ur machine right
rizal.narayan: use rname?
me: root
rizal.narayan: yes
me: password root
3:06 PM rizal.narayan: ok I am in
me: u can make schema as student
cool
u cn create table either by query or mouse
right click on schem name
to create table
3:08 PM rizal.narayan: I have the table now
wired thing in mysql
3:09 PM me: ?
rizal.narayan: if you create a table with id colm it makes it pk by default
me: hmm
but its first column right
rizal.narayan: ok
me: it assumes
rizal.narayan: yes
ok
me: any way
install ruby
3:10 PM rizal.narayan: it doesn't open
setup.rb
me: no
did u installed ruby
3:11 PM rizal.narayan: no
me: install it first
rizal.narayan: I am trying
but it ask for associated program to open
me: thats not the ruby
set up
3:14 PM rizal.narayan: it is downloading
me: cool
rizal.narayan: after installing the aptana studio i installed the rubyon rails plugin as well
me: cool
3:15 PM rizal.narayan: do I need to install again?
me: thats doing with little older version
rizal.narayan: i mean ruby is someting different?
me: might old ruby version
rizal.narayan: oh
me: right v r doing with new
version
3:16 PM rizal.narayan: what components to select?
SciTE, Enable rubyGems??
3:18 PM me: scite
i did not get u
rizal.narayan: i selected all
me: oh np
3:19 PM doesnot matter
rizal.narayan: I installed it
now what?
3:20 PM me: ruby setup.rb
run this
where setup.rb
is there
rizal.narayan: It is installed
3:21 PM me: did u try that
k
rizal.narayan: you send the exe link
me: check gem version by typing this cmd
rizal.narayan: it installed istelf
me: gem --version
3:22 PM rizal.narayan: gives error
me: ?
wht error
rizal.narayan: invalid option -version
me: gem --version
use that
-- not -
3:23 PM rizal.narayan: 0.9.4
me: cool
now run this at cmd line
gem install rails
rizal.narayan: bulk updating
....
me: takes sometime
3:24 PM rizal.narayan: i selected y
me: select all Y
any tie
time
3:26 PM rizal.narayan: it is installing
me: cool
ok
lets go to aptana
rizal.narayan: not finished
me: thats k
we will set up the project
by the time
it completes
3:27 PM rizal.narayan: I am in aptana
me: ok
go to congif folder under the project
look for development.yml
open it
check ur database is conffigured or not
3:28 PM sorry
database.yml
file
rizal.narayan: ok
me: i think its already set up
3:29 PM rizal.narayan: no need to change anything for test, and production right?
me: not now
rizal.narayan: it is done
3:30 PM me: wht abt rails
installed
?
rizal.narayan: done
finished
me: at cmd
rails --version
rizal.narayan: create ....
3:31 PM 2.1.0
me: cool
now u r all set for rails
evreything is instaled
rizal.narayan: ok
me: lets go to aptana
3:32 PM rizal.narayan: can I execute the project
me: yeah
but u hv to do
little more
rizal.narayan: what is that?
me: start the web server
3:33 PM rizal.narayan: You mean the rails server?
build-in preview server running
3:34 PM jaxter internal server running
what else?
me: we dont need those
cl;ick on one cylinder like icon
get drop down
rizal.narayan: connect to generic web server?
me: rails server
3:35 PM not geennric web
wait
3:36 PM dont ping me now

37 minutes
4:13 PM me: rut
4:14 PM rizal.narayan: hello
me: got some work
rizal.narayan: ok
me: i hv to sign out
so did uu star the rails server
rizal.narayan: but is doesn't start
4:15 PM me: did u hit the play button
after adding the server
4:16 PM rizal.narayan: ok it is running now
4:17 PM me: cool
4:18 PM use 3000 port
it suohld show rails introd
rizal.narayan: yes I am getting it
me: u r server is woring fine then
4:19 PM i think now u know right
try with teh yesterdays ur ls
like
/student/new
stuednt/index
4:20 PM rizal.narayan: 500 Internal server error
me: ok
go to log folder look for
development.log

Discussion with rizal on rails-part1

rizal.narayan: Mysql::Error in ExampleController#index
#28000Access denied for user 'root'@'localhost' (using password: NO)
RAILS_ROOT: C:/Users/Rup/Documents/Aptana Studio/example

Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/vendor/mysql.rb:523:in `read'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/vendor/mysql.rb:153:in `real_connect'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/mysql_adapter.rb:471:in `connect'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/mysql_adapter.rb:165:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2-/lib/active_record/query_cache.rb:8:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2-/lib/webrick_server.rb:112:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2-/lib/webrick_server.rb:78:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

1:35 PM me: k
check the database.yml

rizal.narayan: what should i do to connect to the database?
me: database.yml
update it
restart
and then
rizal.narayan: def index
render :partial=>"index"
@example = Example.new(params[:example])
@example.save
I did that
me: create model
rizal.narayan: I have this thing in controller
2:16 PM in model class Example <>
me: go 2 models
s
rizal.narayan: but it is underlined with red
activerecord is having problem
me: send the model file to me
2:17 PM rizal.narayan: this is all I have in model : class Example <>
and the name is example.rb
me: @example = Example.new(params[:example])
from where u got parameters ?
2:18 PM u need a for mo post the data
right
check student one
rizal.narayan: i have form
me: remove partial line index method
2:19 PM rizal.narayan: no no it is working fine
in the partial there is form
with text boxes
me: did create the create action
rizal.narayan: my rendering is correct
me: sendm e he controller
file
rizal.narayan: class ExampleController < partial="">"index"
@example = Example.new(params[:example])
@example.save
end
def addnew

end
end
2:20 PM and in the _index I have
me: oh k
rizal.narayan:

Please fill up the form below before going further




<td><%=text_field("example","name","size"=>20)%>







<%=text_field("example","description","size"=>20)%>
<%= submit_tag "Submit" %>
me: where are the for mtag
?
2:22 PM rizal.narayan: what is that mtag?
me: no
form
tag
rizal.narayan: oh I need to create form
ok ok
2:23 PM me: check my code in _new. rhtml
rizal.narayan: alright
name of the form should be the same as database table name?
2:25 PM me: no
check the syntax
rizal.narayan: i did
<%=form_remote_tag(:url=>{:controller=>'student',:action=>"create"}) %>
me: yeah
rizal.narayan: but did not understand some thing here
can you explain
me: u r posting the data to server
using form
2:26 PM for mcontains user enterd data
to post data u need the url
rizal.narayan: what does create do?
me: here ur cotroller is example
action is create metod
rizal.narayan: it creates what?
me: so in ctroller create metod sud b there
2:27 PM form send params[:example]
rizal.narayan: oh
me: that means

@example = Example.new(params[:example])
@example.save
sud be there in create or some toher metod
2:28 PM rizal.narayan: can I not use create because immediately after this is rendered I am using @example.save
me: index metod is wrong
in ur controller
2:29 PM rizal.narayan: ok
I got it
let me try
me: k
2:32 PM rizal.narayan: SyntaxError in ExampleController#create
2:33 PM me: read there carefully
whts the error
2:34 PM rizal.narayan: actually my model is not functioning I guess
as it is showing syntax error
in active record
me: nop
send me the error
rizal.narayan: C:/Users/Rup/Documents/Aptana Studio/example/app/models/example.rb:1: syntax error, unexpected $end, expecting '\n' or ';'
class Example <>gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:203:in `load_file'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:342:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:202:in `load_file'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:94:in `require_or_load'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:248:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:453:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:465:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:260:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/dependencies.rb:469:in `const_missing'
app/controllers/example_controller.rb:6:in `create'
-e:2:in `load'

2:35 PM me: check the syntax for class
try browser
2:36 PM aptana gives eror mark for syntax
eror
2:37 PM it sud be like tis
class Example <>
end
2:38 PM rizal.narayan: got yah
no end
2:39 PM me: come on
u sud understand these
2:40 PM look for sample rails applications in pdf
and try them
they explain clearly
2:41 PM rizal.narayan: which is the book i shoud lread first
me: any book
for rails
they will give samples
wit hexplanations
u cn just copy paste and try

2:42 PM rizal.narayan: thanks