Tuesday, August 19, 2008

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

No comments: