Skip to content

Instantly share code, notes, and snippets.

@mdamaceno
Last active August 29, 2015 14:05
Show Gist options
  • Save mdamaceno/3f76b506ecaf8a244fd7 to your computer and use it in GitHub Desktop.
Save mdamaceno/3f76b506ecaf8a244fd7 to your computer and use it in GitHub Desktop.
Usual commands in Ruby on Rails
#####################################
#Rails Console
#####################################
# ** Update a user **
u = User.find(id)
u.update_attribute :column, value
# ** Insert a new a user (Devise) **
User.create!({:email => "YOUR_EMAIL", :password => "PASSWORD", :password_confirmation => "PASSWORD", :role => 2 })
# ** View all users **
User.all
# ** Update all values in column **
User.update_all(:column => value)
####################################
# ** Generate secret token
$ rake secret
# Then create a file in config/initializers/secret_token.rb and paste the following:
MyApp::Application.config.secret_token = 'code_generated_by_rake_secret'
####################################
# ** Recompile assets
RAILS_ENV=production rake assets:clean assets:clobber assets:precompile
####################################
# ** Setup for .htaccess using Passenger
PassengerEnabled On
PassengerLoadShellEnvVars On
PassengerAppRoot /root/path/to/railsapp
PassengerRuby /path/to/ruby/on/system # find it with the command '$ which ruby'.
RackEnv production # or development
####################################
# ** Case Ckeditor has problem after assets:precompile
config.assets.enabled = true
config.assets.precompile += Ckeditor.assets
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
####################################
# ** In case of Unicorn not start
# Verify /etc/init.d/unicorn if path of ruby version is correct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment