Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “3.1

Simple Authentication with Rails 3.1

If you need a simple authentication, for example some views that only one person should have access to, you might consider:

http_basic_authenticate_with :name => "username", :password => "pass"

provided by Rails 3.1, it’s a way to protect some pages that only a select few may need access to. Just place that in your controller.
To limit the actions this applies to, you can add :only or :except such as:

http_basic_authenticate_with :name => "username", :password => "pass", :except => :index
Advertisements

Moving to 3.1 on Heroku

Took some lumps moving to 3.1 on Heroku.

Here’s some lessons:

  1. config.assets.initialize_on_precompile = false

    this has to be set per Rails Guides and Heroku.

  2. run “bundle exec rake assets:precompile” locally before pushing to Heroku.  I had a lot of stuff work locally, but when Heroku compiled it, it blew up.  There were a lot of things that I needed to change in my CSS files, working through them one by one
  3. the precompile generated files i uploaded (for the asset
  4. I had a bunch of views with javascript_include_tag and the asset pipeline wasn’t fond of that so I moved it into my application.cs and .js files to use instead
  5. I was getting some errors related to the Sass-rails gem even though it was included in my gemfile.  Turns out I had to move it so that it was outside of this block “group :assets do” that I had it in

Moving to 3.1 on Heroku

Took some lumps moving to 3.1 on Heroku.

Here’s some lessons:

  1. config.assets.initialize_on_precompile = false

    this has to be set per Rails Guides and Heroku.

  2. run “bundle exec rake assets:precompile” locally before pushing to Heroku.  I had a lot of stuff work locally, but when Heroku compiled it, it blew up.  There were a lot of things that I needed to change in my CSS files, working through them one by one
  3. the precompile generated files i uploaded (for the assets), as well as the manifest.yml file
  4. I had a bunch of views with javascript_include_tag and the asset pipeline wasn’t fond of that so I moved it into my application.cs and .js files to use instead