Rails app unable to save anything after deployment - ruby-on-rails

today I uploaded my app to server, and after seting it into development mode, and running of course rake tasks (rake db: migrate, and rade db: migrate RAILS_ENV="production") and well it just doesn't save anything.
The problem happens when I try to create any new items, it just goest to the listing of models...

Your question is very vague. I believe you're saying the app writes files to the server's hard drive. If that's what you're asking, I think the best guess is that something's wrong with file system permissions. Unfortunately, I can't say what is wrong without more details.

i solved it.
reason i asked was because i absolutely went through each and every one of my potential problems and took care of them, and well in the end none of them were the reason of such a failure. so then i went to the basics
and i basically had to clone my development environment on the production machine.
so i had to downgrade rails a couple of versions, and some gems too.
that took care of it, everything went on smoothly, so if anyone ever encounters such mysterous failures, give this a try.

Related

GitKraken Staging too slow after upgrade

So, I've been using gitkraken for awhile and loving it, even considering getting a subscription especially now that they have another thing called Glo - soon to come.
I have recently upgraded GitKraken to v3.3.4. I am not sure whether that was a big mistake but things got a little too annoying. Staging takes a very long time, and you can't do anything when gitkraken is staging files. I read the release notes but there is nothing like this mentioned. Probably just me but would like to know if anyone has the same issue and have you found a way to fix, if ever.
you can try it in your terminal:
codesign --remove-signature /Applications/GitKraken.app/Contents/Frameworks/GitKraken\ Helper\ (Renderer).app

Ruby scaffolding link not working

So I believe that I have searched on here and not found any question that pertains to my issue so hopefully someone can guide me. I was required (for a course) to create a Ruby scaffolding "products" page. My page links all worked on the local host rails server but when I tried it on Heroku (also required) all the links work EXCEPT the new product page.
I have exhaustively googled but I must admit that all the computer lingo is new to me so I am unsure what any of it means and of what steps are safe. For the reason that if I make things worse, I will never know what to look for to reverse anything. I have included the error that shows up in Heroku. When I searched that I found many different answers causing me to be unsure which is correct.
If anything else is needed just let me know. Many thanks to any and all that reply!
Error on Heroku
The error says, "relation products" does not exist.
Did you make sure to run heroku run rake db:migrate ? After you migrate you'll need to heroku restart
This gets me a lot as part of my Heroku deployments, so I make sure to write a script or rake task which does the git push to deploy to Heroku, then runs these two commands. Then I always use that script to deploy, instead of manually doing a push.

Heroku "We're sorry, but something went wrong" after Postgres migration

I recently did Heroku's requested database migration from a "shared database" to Postgres. I followed Heroku's directions carefully, and it all went fine until the last step: removing the old shared database. At that point, my app went down with the "something went wrong" message, and it's been down ever since (going on two weeks now).
Note that the app was still working after the step in which I switched to the new database, and according to "heroku config", it is using the new database. It shouldn't care about the old one disappearing. The logs say nothing other than 500 errors.
I submitted an urgent support request to Heroku, but they were not helpful. They just said that my data is still there but, "Your application isn't logging so it's not clear why this is happening but it doesn't appear to be due to the migration." That was a week ago, so it's not looking like they're going to do anything more.
I agree that the problem shouldn't be due to the migration, but given that I've made no changes to the app except the migration, and that it died exactly when I removed the old database, I don't see what else it could be.
My app is probably pretty old at this point (Rails 3.0.3), so my only thought now is to update everything to the latest versions and redeploy. The app is used to record merit badges and rank advancements for our local Boy Scout troop, so I really need to get it running again. Any advice would be greatly appreciated.
My first instinct would to db:pull the heroku hosted database. (make a copy).
Then try to start your app locally.
Heroku has fixed the problem. My hypothesis was correct: my app was so old that the migration procedure did not actually update it to use the new database. They say that they'll be applying the fix to their other old apps now.
If the app started failing the moment you removed the shared database, it means that your app was still connected to this database and was never connecting to the new one. It sounds to me like you did not run heroku pg:promote HEROKU_POSTGRESQL_<color of new database> --app <your-app>. Can you try that?
Edit:
Based on the further info provided in your comments, it's possible that this is a potential issue in the aspen and bamboo stacks (that only affect a few customers). The thing to try now is a new deploy. Try making a trivial change - maybe a newline in your project README - and deploy the app again. This will force a slug recompile that will write out a new database.yml using the correct DB.
Even better would be to migrate to the cedar stack though

How do I acess/open/edit a .sqlite33 file?

I'm completely new to Ruby on Rails, have never worked on it, but I am supposed to take over somebody else's old project. He designed a webapp that logs into a website/server online, extracts data from it daily and performs calculations. However, the application has not been running for quite some time, so now when it tries to display statistics, the page crashes. It uses data from a 5 week period and currently only has data for 2 days.
I need to manually insert data for the missing weeks in order to get it up and running again, but the problem is I don't know how to find/access its database, nor how exactly to use Ruby on Rails. I found several files in the db directory of his project, however they were mostly .sqlite33 files or just 'files'. I downloaded sqlite precompiled binary for Windows and tried to use it, but not sure what to do. I also downloaded and tried using SQTView to open the files to change the tables, but I have had no luck.
How can I tell which file is the main database and how do I edit it? And what are .sqlite33 files? Thanks.
EDIT
The application produces a
TypeError in HomeController#index
"nil can't be coerced into Float"
It links the error to a line in the code, but the only reason the error happens is because there is no data in the table for the time period that the variable in this line of code tries to use. That is why I want to manually update it with values.
I think that Sqliteman might do the trick and thank-you for explaining all of this to me. I just have to confirm it works after editing.
EDIT2
Okay, so I had a small revelation while experimenting on his app. It turned out that the page crashed because of empty values for full weeks. If I used the app to gather data for at least one day per week up until this week, then the app worked.
Is there a way I can populate all the missing days without having to manually click the days in its calendar because it takes a good 20-30 seconds for it to load?
Thank you very much for your help.
A Rails application's database is defined in config/database.yml - though the database itself and the scheme are in the db folder. In database.yml you'll find three database configurations - development, test and production - so make sure to choose the right file.
I've never heard of .sqlite33 files, but to edit SQLite files manually I recommend SQLiteMan. But I don't recommend editing it manually.
What I do recommend is to check if you are running the app in development or production mode, as the two mods use different databases. Try to run it in the other mode.
If that doesn't work, try saving a copy of the database files, and running the commands:
bundle install
bundle exec rake assets:precompile
rake db:migrate
rake db:migrate RAILS_ENV="production"
(if you're using Linux, you might want to also run the first command with sudo)
Those commands make sure all the required gems are installed, that the precompiled assets are up to date, and that the database fits the schema. If you are running that application on the same machine and with the same database as the ones the other guy was using, than those commands shouldn't be necessary, but if you have moved the application to your own machine, or used an used an outdated db file, than those commands might fix the crash.
At any rate, if you tell us what error the application is producing we might be able to provide more assistance.

Memcache working in production but fails locally

I'm working on an app with a friend and I keep running into errors in my local environment but the app works online (using Heroku). I believe memcache is causing issues in my local environment. Here's what I've done so far:
Added the memcache add-on to my app in Heroku
Installed Homebrew on my machine
Installed memcache using Homebrew with brew install memcached
Then I've restarted my app and ran the memcache process with memcached -vv.
When I access the app it works fine. Then I'll create a record. This also works fine. Then on page reload - when the record is fetched from the cache, the entire app systematically fails. Below is the error I receive (although I'm not sure how much help it is)
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
The error(s) only point to code where memcache is used. A simple user action (i.e. buy a book from a company) triggers the error and once it occurs the entire app is broken (meaning any route leads to the same error). It seems as though its just not storing/fetching the item, which makes me think the app isn't hitting memcache at all...Is it possible I have to gem install something - even though this is working in the production environment and on another dev's machine?
I'm looking for any guidance with troubleshooting memcache. More specifically, has anyone ever run into issues with local vs. production environments in regards to memcache? Any suggestions? I've thought about removing memcache from the app on Heroku, then un-installing it on my computer and then redoing everything.
I know I'm being fairly vague here but I'm not exactly sure what code to post that would help.
Thank you for any help.
After much frustration I began retracing the steps I took to install and implement memcache on my local environment. It didn't make sense how it was working online and with my friend's environment but not mine. Eventually I ran bundle install and then restarted the app and ran a new memcached process and that fixed everything. I'm still a bit confused but I guess my Gemfile just wasn't updated (even though I could've sworn it was).
I use memached without any problems in my environmens, though I do not use Herouku. To access memcached, I have installed the Dalli gem from https://github.com/mperham/dalli
Using it is rather simple.
In the file environment.rb add:
DC = Dalli::Client.new('localhost:11211')
In the application I use
DC.get(key)
DC.delete(key)
DC.set(key,value)
You will first need to test if the keys you're setting are actually getting set or not. You can use Memcached via a Telnet interface to test this.

Resources