My Active Admin Layout Not Comes in Production Environment.
I added in Gemfile
gem 'activeadmin', github: 'gregbell/active_admin'
See My Active Admin Page
Help me Please.
Thanks In Advance
Im using Rails 4 and after running the server in RAILS_ENV=production i would get the same layout as you did, although it works in the development environment. after searching in the web for different answers that one that work for me was the next. Heroku does NOT compile files under assets pipelines in Rails 4 i find the answer here.
add rails_12factor to your gemfile
gem 'rails_12factor', group: :production
then
bundle install
and then restart your server
i did some modifications to config/application.rb file but it never worked for me (somthing to do with precompile assets) therefor i dont think it's necessary.
hope it helps
Related
I am newbie with Heroku and trying to upload a static website to Heroku. Here is what I did with this one.
First, I made a static website named Y , and when I ran localhost:3000, it ran very ok.
Then I followed suggestions from internet, I changed my gemfile
gem 'sqlite3'
to
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
and, change my routes.rb file like this
Rails.application.routes.draw do
get 'home/index'
root 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
But when I tried to run heroku open , it still give me this error
Sorry for my newbie's question, but I am stucking with this one and very confusing. Could you please give me some ideas? Thank you very much.
Check your config/database.yml
You are using pg gem in production but your database.yml file is configured for sqlite3.
It's better to configure your app to use pg on both production and development as well.
You should change your gem file to use gem pg in development
Run bundle install
And then reconfigure your database.yml to use the pg database.
Then run
Rails db:create
Rails db:migrate
And dont forget to add our enviroment variables to heroku so that it can use the database.
I have an existing Rails 3.2.14 application that I am trying to add zurb-foundation to. I have added the zurb-foundation gem and run the installation generator.
My problem is that, whenever I try to load a page, I get this error:
couldn't find file 'foundation'
when Sprockets hits the
//= require foundation
line in application.js
The problem appears to be that the directory with the assets from the zurb-foundation gem are not being added to the load path. In contrast, I have an application that I generated more recently, including zurb-foundation from the beginning, and #asset_paths.asset_environment.paths includes the following
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/js"
which are not included in the asset load path in the app I am updating. Instead, I am getting (with p #asset_paths.asset_environment.paths in the better_errors diagnostic window)
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts"
interestingly, if I run the console in development mode and look at Rails.application.config.assets.path, it includes:
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/js"
and that DOES include the zurb-foundation asset paths.
I have included gem 'zurb-foundation' in the assets group, in the development group, and outside any group. I am using zurb-foundation-4.3.1 in the new app.
My Gemfile assets group is:
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'compass-rails'
gem 'zurb-foundation'
end
This problem seems similar to Sprockets::FileNotFound with ZURB Foundation, although Jurriaan did not mention the asset load path.
Any idea what I could be missing?
Thanks!
Have you tried restarting the webserver?
Update:
You said it runs fine in development, Have you tried to rake assets:clean and rake assets:precompile?
It was a problem with a gem that was preventing foundation's entries being added to the load_path. The gem involved was mongomapper-versioned.
By not loading that gem, the problem resolved. By adding the gem back, the problem recurs.
That gem has not had any activity for two years. I guess it's time to find something else.
I'm using ckeditor_rails (here) but when i uploaded my app to heroku, all my editors wasn't 'ck'ed (lol)
so I started my app (unicorn_rails -E production) and got the same result: even locally, the editors wasn't showing. if I start in development, they work pretty well...
here are my Gemfile (part of)
gem 'mongoid_slug'
# gem 'will_paginate'
gem 'will_paginate_mongoid'
gem 'bootstrap-will_paginate'
gem 'ckeditor_rails', :require => 'ckeditor-rails'
I tried rake tmp:clearand rake assets:precompiled and tried delete the manifest.yml too. none of these commands worked.
am I missing something?
thanks in advance
Did you include the ckeditor-jquery
Make sure that your javascript and css files are included and precompiled
I'm using twitter-bootstrap-rails gem. Last night I updated my gems, and tried using the icon-globe but all i got was an empty space.
here are my Gemfile:
gem 'jquery-rails'
gem 'therubyracer'
gem 'mongoid'
gem 'bson_ext'
gem 'bson'
gem 'mongo'
gem 'devise'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
I tried rake tmp:clearbut this didn't worked too
I just ran into this the other day as well. I have my Rails servers setup so that I can run multiple Rails apps on the same server under their own suburi. Apparently the asset-path helper in the bootstrap_and_overrides.css.less is not including the relative path for the sprites and instead points the background-image url to /assets instead of /suburi/assets.
Following what I found here: https://github.com/rails/rails/issues/3365 I was able to gather that I needed to do the folllowing when precompiling assets:
RAILS_RELATIVE_URL_ROOT="/suburi" rake assets:precompile
This sets the relative root within the environment when you precompile and everything then works as it should.
The thing that really threw me for a loop was that in development everything worked just fine. As soon as I pushed it to the production server the icons stopped showing up. I kept thinking there was an issue with my server or my code. All along it was just the asset-path helper not including the suburi when I precompiled my assets.
Just set your full suburi path in the RAILS_RELATIVE_URL_ROOT environment variable before running the precompile and it will work.
Update: You can set this variable in the config/application.rb file by adding
config.action_controller.relative_url_root = '/suburi'
This would be the best option as it would not require extra typing when deploying.
You can read about it here:
http://guides.rubyonrails.org/configuring.html#configuring-action-controller
did you try:
bundle exec rake assets:precompile
on your production environment?
I'm new to Heroku. I tried pushing a simple test Rails 3.1.1 app to Heroku. The only changes that I made to it from the "new" Rails app template was to create a Home controller and point the root to home#index. I also ran
rails g scaffold Mark type:string start_time:datetime end_time:datetime subject:string measure:float special_event:boolean flag:boolean in_progress:boolean
so that I could run a database migration and test to make sure all showed up properly. The final change that I made was to the Gemfile, which now looks like this:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I followed the Heroku tutorial for this. The push worked, there were no errors reported. I ran heroku rake db:migrate heroku addons:add logging. I also deleted public/index.html from the app. When I run the app locally with rails server, it works fine. I also can manually navigate to the "marks" index, per the scaffold.
When I run heroku open, all I get is the standard We're sorry, but something went wrong. Rails page. heroku logs shows me nothing at all.
What am I doing wrong here? This is about as simple as test cases get, yet I can't get it to work after fiddling with it for hours, creating new apps, deleting this app and trying again, trying to deploy another app, etc.
The problem here is that Rails 3.1 asset pipeline doesn't work 'out of the box' on Bamboo-mri-1.9.2 which is the default when you do heroku create.
The solution is to do heroku create --stack cedar and then push - all will be fine then :)
Try doing this just to see if this works:
rails new stackoverflow
cd stackoverflow/
git init
git add .
git commit -m 'all'
git remote add origin git#github.com:noahc/stackoverflow.git #you'll need to change this
git push origin master
heroku create
git push heroku master
heroku open
If that doesn't work, then it is something to do with your local machine. I just ran through this and it works on my end. See: http://gentle-dawn-1050.heroku.com. If this doesn't fail, I'd try making the changes to the GemFile and see if you can get it to fail that way.
I had the same problem. Looks like you got to the bottom of your issue, but for future problem-havers I want to point out that it could be a discrepancy between the database you use for your local app and the one behind the live app. In my case, my local database was populated, and my Heroku site was empty, since l I didn't properly migrate.
This problem only became apparent when I ran "rake db:reset" in the terminal, (to clear all the data in my local app's database), after which I was able to easily find the bugs in my code.
Conclusion: if the information in your database is negligible, I would suggest clearing it and troubleshooting from there, because it could be that the site you've deployed just doesn't have data yet, and maybe your code doesn't properly handle that kind of exception.......