I try to launch really simple Ruby on Rails app on VDS. I use Nginx, Phusion Passenger and Sqlite3. I have root rights.
Code of creating project:
$ rails new myapplication
$ cd /rails_apps/myapplication
$ bundle install
$ rails generate scaffold Post name:string title:string content:text
$ RAILS_ENV=production rake db:migrate
I can visit main page, it shows ok. But when i try insert data into DB, i get next:
SQLite3::ReadOnlyException: attempt to write a readonly database: INSERT INTO "posts" ("content", "created_at", "name", "title", "updated_at") VALUES (?, ?, ?, ?, ?)
How can i fix that?
UPD:
chmod 777 \db
Helped me.
Still sounds like a privileges issue to me. Make sure that the user that you’re running rails as has permission to edit the file. For instance, if you’re running rails under phusion, I believe that the rails effective user and group are the user and group that nginx runs as. To test if it is permissions. I would start with
chmod 777on your sqlite db file, and see if that helps. If so, follow up to see if you can set the permissions more reasonably and ownership of the db file to your nginx user.