I am using radrails and this error has been killing me…
this is my controller:
def confirmCMSdb
@cmsdbProperties = session[:cmsdbProperties]
for property in params[:cmsdbProperties].keys
#puts property
#puts params[:cmsdbProperties][property]
#puts @cmsdbProperties[property]
@cmsdbProperties[property] = params[:cmsdbProperties][property]
end
session[:cmsdbProperties]
end
def getCMSdbPropsFile
return “config/hibernate.properties.txt”
end
def saveCMSdb
@cmsdbProperties = session[:cmsdbProperties]
cmsdbFile = File.open(getCMSdbPropsFile)
cmsdbFileString = String.new
for line in cmsdbFile
tempLine = String.new
tempLine << line[0]
if tempLine.include?('//')== true
cmsdbFileString += line
end
if tempLine.count("=") > 0 and tempLine.count("=") < 5
tempLine = tempLine.split("=")
#puts "TempLine: " + tempLine
property = tempLine[0].strip
value = tempLine[1].strip
cmsdbFileString += property + "=" +
@cmsdbProperties[property] + “\n”
else
cmsdbFileString += line
end
end
cmsdbFile.close
cmsdbFile = File.open(getCMSdbPropsFile, "w")
cmsdbFile.puts cmsdbFileString
cmsdbFile.close
end
def setCMSdb
cmsdbFile = File.open(getCMSdbPropsFile)
@cmsdbProperties = Hash.new
for line in cmsdbFile
temporaryLine = String.new
temporaryLine << line[0]
if temporaryLine.count("=") > 0 and temporaryLine.count("=") < 5
temporaryLine = temporaryLine.split("=")
#puts "TempLine: " + tempLine
property = temporaryLine[0].strip
value = temporaryLine[1].strip
@cmsdbProperties[property] = value
end
end
cmsdbFile.close
session[:cmsdbProperties] = @cmsdbProperties
end
end
and my views are:
confirmCMSdb:
<% properties = [“mittens.driver”,
“mittens.url”,
“mittens.username”,
“mittens.password”]
propertyTranslate = { “mittens.driver” => “Mittens Driver”,
“mittens.url” => “Database URL”,
“mittens.username” => “Username”,
“mittens.password” => “Password”}%>
Please confirm the following changes to the CMS database Properties
<% form_tag :action => 'saveCMSdb' do %><%= propertyTranslate[property] %> | <%= @cmsdbProperties[property]%> |
---|
<%= submit_tag ‘Submit’ %>
<%end%>
<%= link_to ‘Back’, :action => ‘list’ %>
and setCMSdb:
<% properties = [“mittens.driver”,
“mittens.url”,
“mittens.username”,
“mittens.password”]
propertyTranslate = { “mittens.driver” => “Mittens Driver”,
“mittens.url” => “Database URL”,
“mittens.username” => “Username”,
“mittens.password” => “Password”}%>
Set CMS database Properties
<% form_tag :action => 'confirmCMSdb' do %><%= propertyTranslate[property] %> | <%= text_field :cmsdbProperties, property, {"value" => @cmsdbProperties[property] }%> |
---|
<%= submit_tag ‘Submit’ %>
<%end%>
and in case u need it, this is my text file:
// The mittens driver; for PostgreSQL, use org.postgresql.Driver
(contained in postgresql.jar)
mittens.driver=org.postgresql.Driver
// The url of the database, of the form
jdbc:postgresql://servername:portnumber/databasename for PostgreSQL
mittens.url=jdbc:postgresql://traveltimes.ccit.berkeley.edu:5432/mittenstest
// The username for the database
mittens.username=mittens
// The password for the database
mittens.password=ccit!23
// The dialect to use; use org.hibernate.dialect.PostgreSQLDialect for
PostgreSQL
mittens.dialect=org.hibernate.dialect.PostgreSQLDialect
// JDBC batch size
mittens.batch_size=100
// Should we show SQL ?
mittens.show_sql=false
#dbcp.initialSize=5
#dbcp.maxActive=15
#dbcp.minIdle=2
#dbcp.maxIdle=10
c3p0.acquireIncrement=2
c3p0.initialPoolSize=5
c3p0.minPoolSize=2
c3p0.maxPoolSize=16
c3p0.maxStatements=0
c3p0.numHelperThreads=4
and the error i am getting is the following:
Showing app/views/initial_parameters/setCMSdb.rhtml where line #28
raised:
undefined method `mittens.driver’ for {}:Hash
Plz guys any help is highly appreciated!!!