rake assets:precompile RAILS_ENV=production not working as required

Replace rake assets:precompile RAILS_ENV=production with rake assets:precompile (RAILS_ENV=production bundle exec rake assets:precompile is the exact rake task) Since precompilation is done in production mode only, no need to explicitly specify the environment. Update: Try adding the below line to your Gemfile: group :assets do gem ‘therubyracer’ gem ‘sass-rails’, ” ~> 3.1.0″ gem ‘coffee-rails’, “~> 3.1.0” … Read more

ERROR: ‘rake/rdoctask’ is obsolete and no longer supported. Use ‘rdoc/task’ (available in RDoc 2.4.2+) instead

I had similar problem using rails 2.3.5 so as instructed in the trace message I have edited the Rakefile to require ‘rdoc/task’ instead of rake/rdoctask and installed rdoc gem. If you are using rake version > 10.0.0 . please edit your Rakefile from: require ‘rake’ require ‘rake/testtask’ require ‘rake/rdoctask’ require ‘tasks/rails’ to: require ‘rake’ require … Read more

Seeding users with Devise in Ruby on Rails

You have to do like this: user = User.new user.email=”test@example.com” user.encrypted_password = ‘#$taawktljasktlw4aaglj’ user.save! Read this guide to understand what mass-assignment is: http://guides.rubyonrails.org/security.html I am wondering why do have to directly set the encrypted password. You could do this: user.password = ‘valid_password’ user.password_confirmation = ‘valid_password’

Use active_model_serializer with a non-ActiveRecord object

The model object needs to include it thusly: # active_model_serializers 0.10+ class ModelName include ActiveModel::Serialization end # active_model_serializers < 0.10 class ModelName include ActiveModel::SerializerSupport end This implements the methods needed within the object, and also auto-discovers the serializer matching the object name, so it can be used transparently just like an ActiveRecord object. This works … Read more

strong parameters permit all attributes for nested attributes

The only situation I have encountered where permitting arbitrary keys in a nested params hash seems reasonable to me is when writing to a serialized column. I’ve managed to handle it like this: class Post serialize :options, JSON end class PostsController < ApplicationController … def post_params all_options = params.require(:post)[:options].try(:permit!) params.require(:post).permit(:title).merge(:options => all_options) end end try … Read more

Is it advisable to include the contents of vendor/cache in Git in a Rails 3.2 application?

TL;DR: This is up to you, but I recommend keeping them in git. What vendor/cache does is allow bundling, especially deployment bundling to skip downloading the gems from rubygems. This significantly reduces reliance on rubygems. In deployment, you can specify –local to bundler to completely remove all dependence on rubygems.org, but only if these files … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)