Reputation: 337
I have an iPhone client that is supposed to add records to a Heroku app I made. The problem is no records are being added.
This is my rails code:
Bathroom.Create(name =>params[:name],
:bathroomtype =>params[:bathroomtype],
:street =>params[:street],
:city =>params[:city],
:state =>params[:state],
:country =>params[:country],
:postal =>params[:postal],
:lat =>params[:lat],
:lon =>params[:lon],
:access =>params[:access],
:directions =>params[:directions],
:comment =>params[:comment],
:avail =>params[:avail] )
render :nothing => true
Earlier in my testing, it seemed to work on local server. That makes me think I'm not hitting the production database but I'm not sure how to set that up?
After testing locally, I did a heroku db:push which pushed the database but I'm still not sure that I'm hitting the right thing. No records are being created.
This is my database.yml
development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000
test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000
production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000
So, I'm confused about whether the create code is correct? If so, then why are my entries not showing up in the database?
Any help appreciated.
Upvotes: 0
Views: 93
Reputation: 42178
A few things leap out at me, name
is a bare word instead of a symbol (missing the leading colon), and Create
should be create
. For debugging, you can check to see if validations have failed by looking at Bathroom.create(params).errors.full_messages
. You can also say "if save fails, raise exception" by using create!
instead of create
, and then checking your logs for what died.
Upvotes: 1