# supports only notice and alert by default
# the rest has to go into flash hash
redirect_to :index, notice: "success"
redirect_to :new, notice: "errors"
redirect_to :new, flash: { success: "yeah" }
flash[:info] = "updated"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.dedupe | |
| # find all models and group them on keys which should be common | |
| grouped = all.group_by{|model| [model.title,model.info,model.address,model.phone] } | |
| grouped.values.each do |duplicates| | |
| # the first one we want to keep right? | |
| first_one = duplicates.shift # or pop for last one | |
| # if there are any more left, they are duplicates | |
| # so delete all of them | |
| duplicates.each{|double| double.destroy} # duplicates can now be destroyed | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/custom_logger.rb | |
| class CustomLogger < Logger | |
| def format_message(severity, timestamp, progname, msg) | |
| "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" | |
| end | |
| end | |
| logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file | |
| logfile.sync = true # automatically flushes data to file | |
| CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository | |
| deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main | |
| wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ | |
| sudo apt-key add - | |
| sudo apt-get update | |
| sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6 postgresql-contrib-9.6 -y | |
| sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo -i | |
| cd | |
| apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y | |
| wget http://www.imagemagick.org/download/ImageMagick.tar.gz | |
| tar xzvf ImageMagick-6.8.9-1.tar.gz | |
| cd ImageMagick-6.8.9-1/ | |
| ./configure --prefix=/opt/imagemagick-6.8 && make | |
| checkinstall |
You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.
- postgresql
- postgresql-client
- libpq-dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Country | CountryCode | Currency | Code | |
|---|---|---|---|---|
| New Zealand | NZ | New Zealand Dollars | NZD | |
| Cook Islands | CK | New Zealand Dollars | NZD | |
| Niue | NU | New Zealand Dollars | NZD | |
| Pitcairn | PN | New Zealand Dollars | NZD | |
| Tokelau | TK | New Zealand Dollars | NZD | |
| Australian | AU | Australian Dollars | AUD | |
| Christmas Island | CX | Australian Dollars | AUD | |
| Cocos (Keeling) Islands | CC | Australian Dollars | AUD | |
| Heard and Mc Donald Islands | HM | Australian Dollars | AUD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| # testing rake task app:awesome_report | |
| # defined in file lib/tasks/app/awesome_report.rake | |
| describe 'App::AwesomeReportTaskTest' do | |
| it 'generates the awesomeness report' do | |
| subject.invoke | |
| assert File.exists?('awesomeness_report.csv') | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="redux react todo list example <filter todos>"> | |
| <script src="https://fb.me/react-0.14.7.min.js"></script> | |
| <script src="https://fb.me/react-dom-0.14.7.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.4/redux.js"></script> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> |