Hi,
I tried the sample program for AJAX from the following site.
I created a table called catalogs and set the values.
I tried to load the data while entering the title of the book in the
text field,
I am getting the error messages
=====
SyntaxError in CatalogController#get_article_list
D:/ruby/Projects/catalog/app/models/catalog.rb:14: syntax error,
unexpected ‘)’
I tried to identify the cause of the error.
I colundn’t
This is the controller
class CatalogController < ApplicationController
def index
end
def get_article_list
@section=request.raw_post
@catalogList=“
”
Catalog.find_by_sql( “SELECT * from catalogs WHERE title =
'”+@section+“'” ).each do|catalog|
@catalogList+=“
- <a href="”+catalog.url+“">” +catalog.title+
“ ”
end
@catalogList+=“
”
render :text => @catalogList
end
end
This is model
require ‘rubygems’
require ‘active_record’
class Catalog < ActiveRecord::Base
set_table_name “catalogs”
end
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:database => “mydatabase”,
:username => “root”,
:password =>
)
Please help me to figure out the reason for the error and give your
valuable suggestions.
Thanks in advance.
Ravi
this line
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:database => “mydatabase”,
:username => “root”,
:password =>
)
should have some value for the :password thing.
either use
:password => nil
or
:password => “”
Thorsten M. wrote:
this line
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:database => “mydatabase”,
:username => “root”,
:password =>
)
should have some value for the :password thing.
either use
:password => nil
or
:password => “”
Hi,
After I changed the above modification in the model,
I am getting the following error.
Access denied for user ‘root’@‘localhost’ (using password: NO)
This is my database.yml content
development:
adapter: mysql
encoding: utf8
database: mydatabase
username: root
password: password
host: localhost
The password also set as ‘password’ for the database,
eventhough i gave the password I couldn’t get the out put.
what changes shoule be made.
Thanks in advance,
Ravi
Hi,
Just check this…
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:database => “mydatabase”,
:username => “root”,
:password => “”;
)
I hope this will work.
srinivas reddy wrote:
Hi,
Just check this…
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:database => “mydatabase”,
:username => “root”,
:password => “”;
)
I hope this will work.
Hi,
I tried with the above changes…
still I am having the problem…
herewith I attached the application codes
I am using.
Please any one help me out this…
Thanks in Advance,
Ravi
On Jul 22, 5:44 am, Ravikumar P. <rails-mailing-l…@andreas-
s.net> wrote:
I hope this will work.
Hi,
I tried with the above changes…
still I am having the problem…
Get rid of that semicolon. Putting the mysql connection stuff in the
model class is a bit odd.
Fred
On Jul 21, 1:05 pm, Ravikumar P. <rails-mailing-l…@andreas-
s.net> wrote:
Access denied for user ‘root’@‘localhost’ (using password: NO)
This is my database.yml content
development:
adapter: mysql
encoding: utf8
database: mydatabase
username: root
password: password
host: localhost
You’re not using database.yml because for some reason you’re
establishing the connection by hand in catalog.rb. If you’re going to
go that route then the call to establish_connection must contain valid
credentials (check them in another mysql client first)
Fred