elasticbeanstalk ruby on rails assets - ruby-on-rails

I am new to Ruby on Rails. When I run my rails server on development mode locally, it works fine. I tried deploying to elastic beanstalk (on development mode) but for some reason the assets can't be found. Are there any configurations I need to do in the development.rb or config.yml files?

Related

AWS Elastic beanstalk Ruby App not loading Production ENV

My Ruby on Rails app on AWS Elastic beanstalk is for loading the staging environment, even though it has been configured as production.
BUNDLE_PATH: vendor/bundle
RAILS_ENV: production
RAILS_SKIP_ASSET_COMPILATION: false
RAILS_SKIP_MIGRATIONS: false
BUNDLE_WITHOUT: test:development
RACK_ENV: production
The way i know its loading staging. Is i use the figaro gem to build links in my html.erb files. For instance.
<%= link_to(t('pages.sign_in.forgot_pswd'), "#{ENV['EXTERNAL_LINK_HOME']}/forgot_password", class: 'forgot-pass', target: '_blank')%>
And this link's base URL is the default variable and not production.
application.yml
EXTERNAL_LINK_HOME: 'https://staging.blahblah.com'
production:
EXTERNAL_LINK_HOME: 'https://production.blahblah.com'
This just recently happen on my last deploy. There has been no updates to the figaro gem. The only change was upgrading to the latest AWS Elastic beanstalk instance for Ruby 2.2.
Ruby 2.2 with Puma version 2.3.3 64bit Amazon Linux 2016.09 v2.3.1 running Ruby 2.2 (Puma) 2016.09.0
Ruby 2.2.5-p319
RubyGems 2.4.5.1
Puma 2.16.0
nginx 1.10.1
Rails 4.2.4
I can SSH into the instance, via eb ssh and then cd /var/app/current and run bundle exec rails c. I get a production rails console no problem. verified by Rails.env.

Cap production deploy failed error: could not locate gemfile on AWS server

I am deploying a rails app on a AWS ec2 instance through Capistrano.
Cap production deploy:check is successful, but when I am running cap production deploy I get an error.
Can anyone help?
I found the problem. Your Gemfile in the project was named "gemfile" SMALL g
It must be Gemfile.
So the thing run on Mac and Windows. But when you deploy to Linux, it does not see the Gemfile.Please rename the "gemfile" in your project to "Gemfile"
It will work.

rails console unable to connect to database in staging environment

Using capistrano I'm deploying my Rails 4 app under the environment name "staging". When I ssh onto the server and run rails console, any ActiveRecord queries I do come up with no such table. So I check my Rails.env and sure enough it reads development instead of staging. But even running rails console staging, it does set Rails.env to "staging", but still the ActiveRecord queries say no such table. The app itself is running fine (under Apache and Passenger), but for some reason the rails console is unable to connect to the db.
I've reverted back to when I knew it was working and am still seeing the error, which tells me it is a configuration change i must've made on the server as opposed to a change to the rails app code or capistrano deploy config.
OK, tracked down the answer myself. The RAILS_ENV was originally being set to staging in /etc/environment -- but a while ago this file was removed during some debugging, and not restored.
What does still surprise me is that
rails console staging
does not have the same effect as
export RAILS_ENV=staging
rails console
anyhow, sorted.

Stop assets from being precompiled locally for local production testing of a heroku rails asset_sync s3 app

This app is deployed on heroku and uses asset_sync gem with s3 to serve assets. I want to run my rails server in production locally to test out things before deployment to heroku. When I run rake assets:precompile My local machine uploads files to my s3 bucket (all works fine) but I also notice assets are precompiled in my local public folder.
Precompiling on S3 and locally seems redundant, sometimes I want the assets precompiled to just S3, other times I may want to run a local production server with assets from my public directory and not bother uploading / referencing S3.
So how would I configure my machine to stop assets from being precompiled locally?
I'm open to any ways to configure my system. Right now
I added several variables to my .bash_profile to store my AWS credentials.
export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=yyy
export S3_BUCKET_NAME=my_bucket_name
export FOG_PROVIDER=AWS
export FOG_DIRECTORY=my_bucket_name
I've tried a rails environment/production.rb entry:
config.serve_static_assets = false
Thanks

Rails won't serve static files in production

I recently updated my app from 2.3.8 to 3.0.rc, but after a while in development environment I tried the production environment. But now it won't serve static files.
I use standard development and production environment settings, and have no unique gems for either environments. Everything works like a charm in development, but it won't serve static files in production.
Using ruby-1.8.7-p299 and every gem is up to date. Using WEBrick on my server, running rails s -e production -p 3001
Anyone with some solutions or tips to this ?
After some extra digging I found a setting in the production.rb file, config.serve_static_assets which was set to false, and since I'm not running apache or nginx the static files where not served. blush
For rails 5 you should set environment variable RAILS_SERVE_STATIC_FILES

Resources