Ruby scaffolding link not working - ruby-on-rails

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.

Related

Rails 4 Heroku - changes not getting pushed?

I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today.
I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not sure what code or information is best to supply so please ask me what you think you need to know to help resolve the issue and I will provide it.
My Ruby on Rails app worked fine both locally and on Heroku until I followed the information here to try and serve static images from Amazons S3 bucket. Note I only went as far as the static assets section.
This appeared to stop my Ruby on Rails application from recognising changes in my code. So I would make a change to a HTML file in my editor but the server was serving up the older version of the HTML file, even restarting the server didn't fix this.
I have been searching the web for hours trying to figure out what has gone wrong.
I deleted everything under public assets and I ran the precompile command:
rake assets:precompile
And this seems to have improved things locally, when I edit a HTML file the changes are reflected on localhost. However when I push to Heroku and go to my application hosted on Heroku it still shows the older HTML file no matter how many changes I make and pushes I do to Heroku.
The HTML files that are not updating are located here:
app/assets/templates
I'm not sure what I may have changed that has caused the HTML files not to get updated on Heroku?? What should I look at and try? What other information would be useful in helping track down the issue?
The answer marked as correct in this StackOverflow question worked for me - Updated CSS Stylesheet not loaded following deployment to Heroku? - It looks like I accidently added assets precompiled file in my git repo somewhere along my development and that caused the issue.

Is there a Secret_Key solution for both Heroku prod'n & local dev't envs?

I am trying to find the best solution for storing secret keys (specifically S3 and devise keys are the ones i'm trying to set up) which will enable my app to run both locally and on Heroku. My research so far (almost a whole day on this :( ) shows me a number of options, however i've had issues with each, which i outline below:
Option 1) Using the .gitignored rails 4.1 provided secrets.yml file is lovely in development, you simply use Rails.application.secrets._secret_ in the s3 credentials in your model and all is fine. But when pushing to Heroku you need to heroku config:set key=value for each variable, which in itself is fine but then you need to replace the Rails.application.secrets... syntax with ENV['key'] and this renders the rails intended secrets.yml and the corresponding nice syntax unusable. The only way i can see this working is with ENV's set both locally and on heroku, a bit tedious and it wouldn't be utilising the rails intended secrets.yml file.
Option 2) Using the gem 'figaro' is all well and good, so the gem sets up an application.yml file for you and .gitignores it for you and provides a handy rake command to bulk create Heroku ENV's. But i cannot see how you are meant to use the same app version for both local development and heroku production environments without again having to set ENV's on each environment. Ok, figaro makes setting ENV's quicker on heroku through its rake command, but it still renders secrets.yml useless and involves setting of ENV's for every key in each environment.
Option 3) I found another gem; gem 'heroku_secrets', github: 'alexpeattie/heroku_secrets' which is designed to make our lives easier. This gem, akin with figaro, provides a rake commend to bulk set Heroku ENVs. But i guess it still leaves us with the same issue of ENV's set everywhere. However, i couldn't even get this far with this gem, when attempting to use it I ran into this error message;
git://github.com/alexpeattie/heroku_secrets.git (at master) is not yet checked out. Run bundle install first.
Neither bundle nor bundle install do anything here and searching on the issue has me trying bundle install --deployment which rather than identifying and solving the problem, it provides a workaround solution through placing all of my gems in the vendor directory, not how id like thing set up, so i scrapped that change.
Other Options) dotenv-not tried, foreman-not tried, pre loading a file containing vars before rails.initialize, tried but didn't like.
After all of today searching, playing, trying to implement and re-implement variations of the above and more I am still at a loss as to how to get this app to run on both heroku and local dev environments in a decent way. I would of course like to achieve this whilst using the secrets.yml rails intended set up with without too much customisation, but i will do what i need to do to get this working. I am very much a junior at this developer thing so it is taking me longer than most to get my head around things, but this has really stumped me and has my head firmly in my hands asking for some help, please show me the light oh programming genii.
Here are some of the other links that i found, read and with some tried to implement if of any help with this subject:
Heroku's config man pages: https://devcenter.heroku.com/articles/config-vars#setting-up-config-vars-for-a-deployed-application
A closely related question; How do you manage secret keys and heroku with Ruby on Rails 4.1.0beta1?
Article on various solutions; http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails
Another article on various solutions; http://tammersaleh.com/posts/managing-heroku-environment-variables-for-local-development/
Bundle 'not checked out' error; is not checked out... bundle install does NOT fix help!
Yet despite all of this discussion I can't seem to find a way to get this to work in both development local and heroku production environments without manually setting ENVs. Is there a way and if so would you please enlighten me.

Trouble with Heroku Deployment and Interpreting Heroku Log

This is my last resort to figure this out. I've searched through stackoverflow and googled various topics, but it seems to come down to how to interpret/analyze my own Heroku log. There's so much going on that I'm not sure where to look first. I see things like eager_load and direction to files app/config/environment:rb:5 and there also seems to be issues with my Unicorn configurations and relationship associations. I've gone through my files and haven't been able to locate what my logs are referring to, up until now it's been really easy to interpret errors.
A little background: I had originally built my rails app with the default Sqlite3 settings and I have attempted to switch it to Postgres. So maybe there's some conflicts with that going on as well. I want to be able to read my Heroku Logs in the future on my own and know exactly where to look. So if someone could provide a good tutorial about reading Heroku Logs that would be great as well.
Here's where I've looked so far:
I've looked on devcenter on heroku's website, but I'm not making the connection from their instructions, to the issue in my code. I'm just a that stuck point, but have been trying to figure it out for days! I'm worried that I'm just missing something basic, which is why I haven't been able to figure this out yet.
I've also looked at association_basics.html on ruby on rails guides because I've been having some syntax issues.
I've used foreman start to see if my Procfile is working and have gotten another huge list. I've also used heroku ps, which gives me web.1 crashed
Here's the Heroku Log that's also connected to my app's github page:
https://github.com/jsmit032/seasons-app/issues/29
If any other information is required, please let me know and I'll edit my questions so hopefully this can help others as well.
2014-11-21T19:27:58.271705+00:00 app[web.1]: has_many :user, through :user_to_destinations
doesn't look right - it should be
has_many :user, through: :user_to_destinations
at /app/app/models/destination.rb:3
So I got the whole app to deploy! Turns out it was a pre-complied issue.
So I went through the guide on Heroku for pre-compiling assets in Rails 4: https://devcenter.heroku.com/articles/rails-4-asset-pipeline
I also went through the heroku guide for prepping your rails 4 app:
https://devcenter.heroku.com/articles/getting-started-with-rails4#migrate-your-database
Also went through the heroku guide for SQLite on Heroku and the Deploying Rails Applications with Unicorn guide.
Looking through the console errors on the actual site was a huge help. It's how we figured out that the assets pipeline might not be working.

How to get this simple rails project to work on Heroku?

I followed this tutorial to make a simple website where you can enter blog entries. I was able to get it working with a postgresql database on my computer.
Then I pushed it to heroku. It was accepted and everything seemed fine.
When I tried to go to the page in my browser though, it didn't work right. You can see it here.
I even tried setting up a shared postgresql database on Heroku. Am I supposed to make some changes to database.yml to get it to work?
One thing I noticed though is that what I added in the shared postgresql database, the error messages seem to indicate that it does find a database, but doesn't find the table. Am I right? I tried to manually recreate the table using the heroku console, but wasn't able to.
What's going on here? How can I get this to work?
Have you tried heroku run rake db:migrate yet?
If that doesn't fix it what does heroku logs --tail tell you?

Rails app unable to save anything after deployment

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.

Resources