# Where is my data?

**URL:** <https://www.ruby-forum.com/t/where-is-my-data/210592>\
**Category:** Rails\
**Created:** [August 11, 2011, 6:20pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592 "2011-08-11T18:20:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 11, 2011, 6:20pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/1 "2011-08-11T18:20:03Z")

</div>

I have started a rails application I call ‘timecard’ using postgresql  
as it’s back-end.  
(rails 3.0.7 on a Suse Linux machine)

I edited the database.yml file to point to the dev prod and test  
databases with proper user and password.

I created the basic tables, models etc. using ‘rails generate  
controller’ and ‘rails generate scaffold’ and ‘rake db:migrate’ and  
everything seems ok.

I started the rails server and pointed firefox at the proper url’s and  
everything is a go.

Here is where it gets wierd. I just added 4 more records (using the  
rails page with Firefox) to a table I originalled added 2 records to  
last week. All the records show when I navigate to the proper url.  
But when I directly access the table using the postgresql utility  
‘psql’ only the 2 records I added last week are listed! I wanted to  
get the key id values of the records, which doesn’t show on the  
generic rails page, but the records aren’t there!

Is some kind of caching going on? I exited Firefox but that didn’t  
force the records into the table, so what am I seeing in the rails  
page, and where is my data?

Thanks in advance for any help. --Fred

---

<div class="post-metadata">

**Author:** ![fredrated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@fredrated](https://www.ruby-forum.com/u/fredrated)\
**Post date:** [August 11, 2011, 6:43pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/2 "2011-08-11T18:43:31Z")

</div>

On Thu, Aug 11, 2011 at 1:15 PM, fredrated [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I started the rails server and pointed firefox at the proper url’s and  
> everything is a go.
> 
> Here is where it gets wierd. I just added 4 more records (using the  
> rails page with Firefox) to a table I originalled added 2 records to  
> last week. All the records show when I navigate to the proper url.  
> But when I directly access the table using the postgresql utility  
> ‘psql’ only the 2 records I added last week are listed! I wanted to  
> get the key id values of the records, which doesn’t show on the  
> generic rails page, but the records aren’t there!

Can you confirm your connecting to the same database from the rails  
app and from psql?  
Are you sure the index page doesn’t have the data harcoded somewhere?  
Have you tried copying the database with a different name and change  
your app to use the new database?  
Do you have your tests in place?

> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Leonardo M..  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![fredrated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@fredrated](https://www.ruby-forum.com/u/fredrated)\
**Post date:** [August 11, 2011, 7:46pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/3 "2011-08-11T19:46:40Z")

</div>

> > “Can you confirm your connecting to the same database from the rails  
> > app and from psql?”

I started the webrick server in /home/work/timecard so it must be  
pointing to the rails timecard app. and the database is specified in  
database.yml, beyond that how do I determine the database I am using?

> > “Are you sure the index page doesn’t have the data harcoded somewhere?”

I have opened all of the standard .html.erb files in the app/views/  
timeperiods directory and verified there is nothing there beyond the  
rails defaults.

> > "Have you tried copying the database with a different name and change  
> > your app to use the new database?

Not a bad idea so I used psql to clone the database and edited  
database.yml in rails to refer to the new database. psql still shows  
only 2 records. After restarting the rails server then navigating to  
the url I now get “Fatal: database ‘mymystery’ does not exist”.  
Edited database.yml back to timecard\_development, restarted the rails  
server, and the url works again but shows all 6 records. Don’t  
understand why rails couldn’t find my new database ‘mymystery’.

It seems clear we are not looking at the same data. I listed all  
databases on my (VMWhere virtual) machine, opened and queried them all  
with psql, and none of them have the records I added through the rails  
interface.

> > “Do you have your tests in place?”

Actually, no. I guess I’m a slow learner because I do best focusing  
on one thing at a time, and for now I want to focus Rails. I will add  
what is needed for TDD after I have reached some familiarty with  
Rails.

Thanks for looking at my problem, if you think of anything else to try  
please comment. --Fred

---

<div class="post-metadata">

**Author:** ![fredrated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@fredrated](https://www.ruby-forum.com/u/fredrated)\
**Post date:** [August 11, 2011, 9:44pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/4 "2011-08-11T21:44:52Z")

</div>

Mystery solved: the following 2 lines in database.yml were directing  
me to another server on our internal network, where the files were  
being read from and written to:

host: 198.31.87.25  
port: 5432

Now I have to figure out why, after I comment-out the host and port  
lines, I get “could not connect to server: no such file or directory”  
when I try to access the Rails url’s. It’s a start!

Thanks everyone for your assistance. --Fred

---

<div class="post-metadata">

**Author:** ![fredrated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@fredrated](https://www.ruby-forum.com/u/fredrated)\
**Post date:** [August 11, 2011, 9:32pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/5 "2011-08-11T21:32:28Z")

</div>

On 11 August 2011 18:45, fredrated [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> timeperiods directory and verified there is nothing there beyond the  
> server, and the url works again but shows all 6 records. Don’t  
> understand why rails couldn’t find my new database ‘mymystery’.
> 
> It seems clear we are not looking at the same data. I listed all  
> databases on my (VMWhere virtual) machine, opened and queried them all  
> with psql, and none of them have the records I added through the rails  
> interface.

Please post your complete database.yml

Colin

---

<div class="post-metadata">

**Author:** ![fredrated](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/76d3ee/32.png) [@fredrated](https://www.ruby-forum.com/u/fredrated)\
**Post date:** [August 11, 2011, 9:54pm UTC](https://www.ruby-forum.com/t/where-is-my-data/210592/6 "2011-08-11T21:54:10Z")

</div>

On 11 August 2011 20:42, fredrated [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Mystery solved: the following 2 lines in database.yml were directing  
> me to another server on our internal network, where the files were  
> being read from and written to:
> 
> host: 198.31.87.25  
> port: 5432
> 
> Now I have to figure out why, after I comment-out the host and port  
> lines, I get “could not connect to server: no such file or directory”  
> when I try to access the Rails url’s. It’s a start!

You have to put the correct host in - localhost possibly

Colin
