Best Asset Pipeline Setup for Ruby on Rails and Heroku - ruby-on-rails-3

I am running Rails 3.2.12 and deploying to Heroku.
Currently, to get my css files to update locally I need to run
RAILS_ENV=production bundle exec rake assets:precompile
I was wondering how I can get my asset pipeline to start automatically updating upon sacing again in development mode.
I have read the following article, but I am unsure which set up to follow. I am just using basic scss, nothing crazy.
https://devcenter.heroku.com/articles/rails-asset-pipeline
Thank you.

Related

Images load slowly in ruby on rails

I have developed a website using ruby 1.9.3 and deployed in on aws server through passenger. But my website takes time in loading.
I am using passenger in: production mode
I am worried because i reduced the size of images to 100kb even then they took time in loading due to which animation can't occur properly.
I have assets precompile :true
in production environment.
Is there any way to load images fast.
Please help i am new to ruby
Thanks & Regards
Rajat
If you are using asset pipeline, then you need precompile assets using the rake task and deploy the application to production.
bundle exec rake assets:precompile
Refer to below links for more info
http://guides.rubyonrails.org/asset_pipeline.html
http://stackoverflow.com/questions/8821864/config-assets-compile-true-in-rails-production-why-not

heroku pg:reset breaks everything

I was trying to reset the seed data in my heroku database for an app i'm building and the developer site from heroku says to use heroku pg:reset DATABASE to do so.
After doing this and migrating my database again heroku run rake db:migrate followed by re-seeding with heroku run rake db:seed I cannot migrate any apps. even new ones. I don't know if a schema will help. It was not a database problem I was trying to fix, just a removal of repeated records.

activeadmin formatting error on rails 3 app

I recently migrated a rails 3 app from a Mac OS X environment to a Debian server. The migration succeeded, the app is running through the WEBrick server but the formatting that had originally come with the activeadmin gem has disappeared from most views. The form is still accessible and functioning but it is in the default html formatting.
However http://domainexample.com:3000/admin still has the custom formatting, any ideas of why this has happened?
In my troubleshooting:
reinstalled activeadmin with
rails generate active_admin:install
When I run
rake db:migrate
got devise errors so dropped the databases and ran
rake db:create
rails s still works and boots the server but
rake db:migrate throws an error:
Mysql2::Error: Table 'admin_users' already exists
UPDATE:
This fixed the problem, but I don't understand why.
had to copy the active_admin.css as active_admin.css.dup.css file from my local and upload it to the server version in app/assets/stylesheets. The server version was implementing namespaces for some reason.

Rails assets images in production

I found some strange behavior of assets images
If I run unicorn in production mode at hosting - /assets/image.png - server give me blank image ie file exist, but size=0 . In same time at localhost I run in unicorn development mode - and all works fine, Then I run webrick at hosting - images are display fine. After that I run unicorn in production mode at localhost and images stops display, then I run unicorn in development images already doesn't work.
Rails 3.1.0.rc6, after that I update to rc8 at hosting but nothing happened
Maybe production mode build some cache, which remains forever?
There are different things that may go wrong, so here the ideas you have to check:
There is a known error in Rails 3.1, that the precompilation of assets does not work properly. See Upgrade to Rails 3.1.0 from rc6, asset precompile fails for a question with a solution.
I had problems with creating precompiled assets for production. The following worked for me (after fixing the error above):
Ensure that your application is not running in production mode.
Call bundle exec rake assets:clean. This will clean all resources hanging around.
Call bundle exec rake assets:precompile afterwards. As a result, the directory /public/assets should be filled with assets with the hash appended (e.g. icon_add-96985e087048a8c2e09405494509750d.gif instead of icon-add.gif).
Start your server in production mode.
Depending on the browser I used, I had to refresh or even clear all caches. Especially Chrome was very nasty in caching resources that he should not cache.
I hope some of the ideas will help you find the source of your problem.

How to install paper_trail plugin on Rails 3

I'm sure this is astonishingly straightforward, and I'm just inexperienced with Rails 3, but I can't figure out how to make it work.
I'm trying to install the paper_trail plugin into my Rails 3 app; but the instructions seem designed for Rails 2. I'm running under Windows, and don't have git available.
I've tried putting gem 'paper_trail' into my Gemfile and running bundle install, which picked up the gem correctly; but rails generate paper_trail (which I assume is the new form of script/generate paper_trail fails with Could not find generator paper_trail.
Can anyone give me some step-by-step instructions to get this working?
A little late to the party. I am writing this since I found the thread through Google. Here is how I got it to work with Rail 3.0.9. I was getting the same error with
bundle exec rails generate paper_trail
as well as
bundle exec rails g paper_trail
and
rails generate paper_trail
Turns out, you need to run
bundle exec rails generate paper_trail:install
that generated the migration file for me and a
bundle exec rake db:migrate
created the table.
As of 11 October, rails generate paper_trail works as you would expect.
I've managed to make this work by simply downloading the zipped code from github, unpacking it into vendor/plugins, installing the gem (through Gemfile and bundle install), and then copy-pasting the migration code in paper_trail's generator into a blank migration of the same name.