8 |
9 | {@props.children}
10 |
11 |
--------------------------------------------------------------------------------
/app/frontend/reducers/index.coffee:
--------------------------------------------------------------------------------
1 | { combineReducers } = require 'redux'
2 |
3 | module.exports = combineReducers
4 | people: require './people'
5 | person: require './person'
6 |
--------------------------------------------------------------------------------
/app/frontend/reducers/people.coffee:
--------------------------------------------------------------------------------
1 | constants = require '../constants'
2 |
3 | initialState =
4 | people: null
5 | meta: {}
6 | search: ''
7 | isLoading: false
8 | pageNumber: 1
9 |
10 | module.exports = (state = initialState, action) ->
11 | switch action.type
12 | when constants.REQUEST_PEOPLE
13 | Object.assign {}, state, pageNumber: action.pageNumber, search: action.search
14 |
15 | when constants.SET_SEARCH
16 | Object.assign {}, state, search: action.search
17 |
18 | when constants.RECEIVE_PEOPLE
19 | newState =
20 | people: action.people
21 | meta: action.meta
22 | isLoading: false
23 |
24 | Object.assign {}, state, newState
25 |
26 | else
27 | state
28 |
--------------------------------------------------------------------------------
/app/frontend/reducers/person.coffee:
--------------------------------------------------------------------------------
1 | { REQUEST_PERSON, RECEIVE_PERSON } = require '../constants'
2 |
3 | initialState =
4 | person: {}
5 | isLoading: false
6 |
7 | module.exports = (state = initialState, action) ->
8 | switch action.type
9 | when REQUEST_PERSON
10 | Object.assign {}, state, isLoading: true
11 |
12 | when RECEIVE_PERSON
13 | Object.assign {}, state, action.person, isLoading: false
14 |
15 | else
16 | state
17 |
--------------------------------------------------------------------------------
/app/frontend/routes/index.cjsx:
--------------------------------------------------------------------------------
1 | MainLayout = require '../layouts/main'
2 | { Route } = require 'react-router'
3 | PeopleList = require '../components/people/list'
4 | Person = require '../components/people/person'
5 |
6 | module.exports =
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/frontend/store/configure_store.coffee:
--------------------------------------------------------------------------------
1 | { createStore, applyMiddleware } = require 'redux'
2 | thunkMiddleware = require 'redux-thunk'
3 | loggerMiddleware = require 'redux-logger'
4 | rootReducer = require '../reducers'
5 |
6 | logger = loggerMiddleware
7 | level: 'info',
8 | collapsed: true
9 |
10 | createStoreWithMiddleware = applyMiddleware(thunkMiddleware, logger)(createStore)
11 |
12 | configureStore = (initialState) ->
13 | createStoreWithMiddleware rootReducer, initialState
14 |
15 | module.exports = configureStore
16 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/app/mailers/.keep
--------------------------------------------------------------------------------
/app/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/app/models/.keep
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/app/models/concerns/.keep
--------------------------------------------------------------------------------
/app/models/person.rb:
--------------------------------------------------------------------------------
1 | # == Schema Information
2 | #
3 | # Table name: people
4 | #
5 | # id :integer not null, primary key
6 | # first_name :string not null
7 | # last_name :string
8 | # gender :integer default("0")
9 | # birth_date :date
10 | # location :string
11 | # phone_number :string
12 | # email :string
13 | # headline :text
14 | # created_at :datetime not null
15 | # updated_at :datetime not null
16 | # picture :string
17 | #
18 |
19 | class Person < ActiveRecord::Base
20 | include PgSearch
21 |
22 | enum gender: [:male, :female]
23 |
24 | scope :sorted, ->{ order(first_name: :asc) }
25 | pg_search_scope :search,
26 | against: [
27 | :first_name,
28 | :last_name,
29 | :location,
30 | :headline
31 | ],
32 | using: {
33 | tsearch: {
34 | prefix: true,
35 | normalization: 2
36 | }
37 | }
38 | end
39 |
--------------------------------------------------------------------------------
/app/serializers/person_serializer.rb:
--------------------------------------------------------------------------------
1 | class PersonSerializer < ActiveModel::Serializer
2 | attributes :id,
3 | :first_name,
4 | :last_name,
5 | :full_name,
6 | :gender,
7 | :birth_date,
8 | :location,
9 | :phone_number,
10 | :email,
11 | :headline,
12 | :picture
13 |
14 | def full_name
15 | [object.first_name, object.last_name].join(' ')
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/views/home/index.html.haml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.haml:
--------------------------------------------------------------------------------
1 | !!!
2 | %html
3 | %head
4 | %title Rails and Redux: A real use case
5 | = include_gon
6 | %link{href: "https://fonts.googleapis.com/css?family=Fjalla+One|Average+Sans", rel: "stylesheet", type: "text/css"}/
7 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
8 | = javascript_include_tag 'application', 'data-turbolinks-track' => true
9 | = csrf_meta_tags
10 | %body
11 | #main_wrapper
12 | = yield
13 | %footer#main_footer
14 | %small
15 | Crafted with ♥ by
16 | %a{href: "http://codeloveandboards.com", target:"_blank"} bigardone
17 | %br/
18 | Check out the
19 | %a{href: "https://github.com/bigardone/rails_and_redux", target: '_blank'} source code
20 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | APP_PATH = File.expand_path('../../config/application', __FILE__)
7 | require_relative '../config/boot'
8 | require 'rails/commands'
9 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path("../spring", __FILE__)
4 | rescue LoadError
5 | end
6 | require_relative '../config/boot'
7 | require 'rake'
8 | Rake.application.run
9 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 |
4 | # path to your application root.
5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6 |
7 | Dir.chdir APP_ROOT do
8 | # This script is a starting point to setup your application.
9 | # Add necessary setup steps to this file:
10 |
11 | puts "== Installing dependencies =="
12 | system "gem install bundler --conservative"
13 | system "bundle check || bundle install"
14 |
15 | # puts "\n== Copying sample files =="
16 | # unless File.exist?("config/database.yml")
17 | # system "cp config/database.yml.sample config/database.yml"
18 | # end
19 |
20 | puts "\n== Preparing database =="
21 | system "bin/rake db:setup"
22 |
23 | puts "\n== Removing old logs and tempfiles =="
24 | system "rm -f log/*"
25 | system "rm -rf tmp/cache"
26 |
27 | puts "\n== Restarting application server =="
28 | system "touch tmp/restart.txt"
29 | end
30 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast
4 | # It gets overwritten when you run the `spring binstub` command
5 |
6 | unless defined?(Spring)
7 | require "rubygems"
8 | require "bundler"
9 |
10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12 | ENV["GEM_HOME"] = ""
13 | Gem.paths = ENV
14 |
15 | gem "spring", match[1]
16 | require "spring/binstub"
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | # Pick the frameworks you want:
4 | require "active_model/railtie"
5 | require "active_record/railtie"
6 | require "action_controller/railtie"
7 | require "action_mailer/railtie"
8 | require "action_view/railtie"
9 | require "sprockets/railtie"
10 | # require "rails/test_unit/railtie"
11 |
12 | # Require the gems listed in Gemfile, including any gems
13 | # you've limited to :test, :development, or :production.
14 | Bundler.require(*Rails.groups)
15 |
16 | module RailsAndRedux
17 | class Application < Rails::Application
18 | # Settings in config/environments/* take precedence over those specified here.
19 | # Application configuration should go into files in config/initializers
20 | # -- all .rb files in that directory are automatically loaded.
21 |
22 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
23 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
24 | # config.time_zone = 'Central Time (US & Canada)'
25 |
26 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
27 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
28 | # config.i18n.default_locale = :de
29 |
30 | # For not swallow errors in after_commit/after_rollback callbacks.
31 | config.active_record.raise_in_transactional_callbacks = true
32 |
33 | # sass over scss
34 | config.sass.preferred_syntax = :sass
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | default: &default
2 | adapter: postgresql
3 | host: localhost
4 |
5 | development:
6 | <<: *default
7 | database: rails_and_redux_development
8 |
9 | test:
10 | <<: *default
11 | database: rails_and_redux_test
12 |
13 | production:
14 | <<: *default
15 | database: rails_and_redux_production
16 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations.
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true
29 |
30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31 | # yet still be able to expire them through the digest params.
32 | config.assets.digest = true
33 |
34 | # Adds additional error checking when serving assets at runtime.
35 | # Checks for improperly declared sprockets dependencies.
36 | # Raises helpful error messages.
37 | config.assets.raise_runtime_errors = true
38 |
39 | # Raises error for missing translations
40 | # config.action_view.raise_on_missing_translations = true
41 | end
42 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like NGINX, varnish or squid.
20 | # config.action_dispatch.rack_cache = true
21 |
22 | # Disable Rails's static asset server (Apache or NGINX will already do this).
23 | config.serve_static_assets = false
24 |
25 | # Compress JavaScripts and CSS.
26 | config.assets.js_compressor = :uglifier
27 | # config.assets.css_compressor = :sass
28 |
29 | # Do not fallback to assets pipeline if a precompiled asset is missed.
30 | config.assets.compile = false
31 |
32 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
33 | # yet still be able to expire them through the digest params.
34 | config.assets.digest = true
35 |
36 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
37 |
38 | # Specifies the header that your server uses for sending files.
39 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41 |
42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43 | # config.force_ssl = true
44 |
45 | # Set to :info to decrease the log volume.
46 | config.log_level = :debug
47 |
48 | # Prepend all log lines with the following tags.
49 | # config.log_tags = [ :subdomain, :uuid ]
50 |
51 | # Use a different logger for distributed setups.
52 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53 |
54 | # Use a different cache store in production.
55 | # config.cache_store = :mem_cache_store
56 |
57 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58 | # config.action_controller.asset_host = "http://assets.example.com"
59 |
60 | # Ignore bad email addresses and do not raise email delivery errors.
61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
62 | # config.action_mailer.raise_delivery_errors = false
63 |
64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
65 | # the I18n.default_locale when a translation cannot be found).
66 | config.i18n.fallbacks = true
67 |
68 | # Send deprecation notices to registered listeners.
69 | config.active_support.deprecation = :notify
70 |
71 | # Use default logging formatter so that PID and timestamp are not suppressed.
72 | config.log_formatter = ::Logger::Formatter.new
73 |
74 | # Do not dump schema after migrations.
75 | config.active_record.dump_schema_after_migration = false
76 | end
77 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure static asset server for tests with Cache-Control for performance.
16 | config.serve_static_assets = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Print deprecation notices to the stderr.
35 | config.active_support.deprecation = :stderr
36 |
37 | # Raises error for missing translations
38 | # config.action_view.raise_on_missing_translations = true
39 | end
40 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/kaminari_config.rb:
--------------------------------------------------------------------------------
1 | Kaminari.configure do |config|
2 | config.default_per_page = 9
3 | # config.max_per_page = nil
4 | # config.window = 4
5 | # config.outer_window = 0
6 | # config.left = 0
7 | # config.right = 0
8 | # config.page_method_name = :page
9 | # config.param_name = :page
10 | end
11 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_rails_and_redux_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/config/newrelic.yml:
--------------------------------------------------------------------------------
1 | #
2 | # This file configures the New Relic Agent. New Relic monitors Ruby, Java,
3 | # .NET, PHP, Python and Node applications with deep visibility and low
4 | # overhead. For more information, visit www.newrelic.com.
5 | #
6 | # Generated September 06, 2014
7 | #
8 | # This configuration file is custom generated for bigardone
9 |
10 |
11 | # Here are the settings that are common to all environments
12 | common: &default_settings
13 | # ============================== LICENSE KEY ===============================
14 |
15 | # You must specify the license key associated with your New Relic
16 | # account. This key binds your Agent's data to your account in the
17 | # New Relic service.
18 | license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
19 |
20 | # Agent Enabled (Ruby/Rails Only)
21 | # Use this setting to force the agent to run or not run.
22 | # Default is 'auto' which means the agent will install and run only
23 | # if a valid dispatcher such as Mongrel is running. This prevents
24 | # it from running with Rake or the console. Set to false to
25 | # completely turn the agent off regardless of the other settings.
26 | # Valid values are true, false and auto.
27 | #
28 | # agent_enabled: auto
29 |
30 | # Application Name Set this to be the name of your application as
31 | # you'd like it show up in New Relic. The service will then auto-map
32 | # instances of your application into an "application" on your
33 | # dashboard page. If you want to map this instance into multiple
34 | # apps, like "AJAX Requests" and "All UI" then specify a semicolon
35 | # separated list of up to three distinct names, or a yaml list.
36 | # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
37 | # Production, Staging, etc)
38 | #
39 | # Example:
40 | #
41 | # app_name:
42 | # - Ajax Service
43 | # - All Services
44 | #
45 | # Caution: If you change this name, a new application will appear in the New
46 | # Relic user interface with the new name, and data will stop reporting to the
47 | # app with the old name.
48 | #
49 | # See https://newrelic.com/docs/site/renaming-applications for more details
50 | # on renaming your New Relic applications.
51 | #
52 | app_name: Rails and Flux
53 |
54 | # When "true", the agent collects performance data about your
55 | # application and reports this data to the New Relic service at
56 | # newrelic.com. This global switch is normally overridden for each
57 | # environment below. (formerly called 'enabled')
58 | monitor_mode: true
59 |
60 | # Developer mode should be off in every environment but
61 | # development as it has very high overhead in memory.
62 | developer_mode: false
63 |
64 | # The newrelic agent generates its own log file to keep its logging
65 | # information separate from that of your application. Specify its
66 | # log level here.
67 | log_level: info
68 |
69 | # Optionally set the path to the log file This is expanded from the
70 | # root directory (may be relative or absolute, e.g. 'log/' or
71 | # '/var/log/') The agent will attempt to create this directory if it
72 | # does not exist.
73 | # log_file_path: 'log'
74 |
75 | # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
76 | # log_file_name: 'newrelic_agent.log'
77 |
78 | # The newrelic agent communicates with the service via https by default. This
79 | # prevents eavesdropping on the performance metrics transmitted by the agent.
80 | # The encryption required by SSL introduces a nominal amount of CPU overhead,
81 | # which is performed asynchronously in a background thread. If you'd prefer
82 | # to send your metrics over http uncomment the following line.
83 | # ssl: false
84 |
85 | #============================== Browser Monitoring ===============================
86 | # New Relic Real User Monitoring gives you insight into the performance real users are
87 | # experiencing with your website. This is accomplished by measuring the time it takes for
88 | # your users' browsers to download and render your web pages by injecting a small amount
89 | # of JavaScript code into the header and footer of each page.
90 | browser_monitoring:
91 | # By default the agent automatically injects the monitoring JavaScript
92 | # into web pages. Set this attribute to false to turn off this behavior.
93 | auto_instrument: true
94 |
95 | # Proxy settings for connecting to the New Relic server.
96 | #
97 | # If a proxy is used, the host setting is required. Other settings
98 | # are optional. Default port is 8080.
99 | #
100 | # proxy_host: hostname
101 | # proxy_port: 8080
102 | # proxy_user:
103 | # proxy_pass:
104 |
105 | # The agent can optionally log all data it sends to New Relic servers to a
106 | # separate log file for human inspection and auditing purposes. To enable this
107 | # feature, change 'enabled' below to true.
108 | # See: https://newrelic.com/docs/ruby/audit-log
109 | audit_log:
110 | enabled: false
111 |
112 | # Tells transaction tracer and error collector (when enabled)
113 | # whether or not to capture HTTP params. When true, frameworks can
114 | # exclude HTTP parameters from being captured.
115 | # Rails: the RoR filter_parameter_logging excludes parameters
116 | # Java: create a config setting called "ignored_params" and set it to
117 | # a comma separated list of HTTP parameter names.
118 | # ex: ignored_params: credit_card, ssn, password
119 | capture_params: false
120 |
121 | # Transaction tracer captures deep information about slow
122 | # transactions and sends this to the New Relic service once a
123 | # minute. Included in the transaction is the exact call sequence of
124 | # the transactions including any SQL statements issued.
125 | transaction_tracer:
126 |
127 | # Transaction tracer is enabled by default. Set this to false to
128 | # turn it off. This feature is only available at the Professional
129 | # and above product levels.
130 | enabled: true
131 |
132 | # Threshold in seconds for when to collect a transaction
133 | # trace. When the response time of a controller action exceeds
134 | # this threshold, a transaction trace will be recorded and sent to
135 | # New Relic. Valid values are any float value, or (default) "apdex_f",
136 | # which will use the threshold for an dissatisfying Apdex
137 | # controller action - four times the Apdex T value.
138 | transaction_threshold: apdex_f
139 |
140 | # When transaction tracer is on, SQL statements can optionally be
141 | # recorded. The recorder has three modes, "off" which sends no
142 | # SQL, "raw" which sends the SQL statement in its original form,
143 | # and "obfuscated", which strips out numeric and string literals.
144 | record_sql: obfuscated
145 |
146 | # Threshold in seconds for when to collect stack trace for a SQL
147 | # call. In other words, when SQL statements exceed this threshold,
148 | # then capture and send to New Relic the current stack trace. This is
149 | # helpful for pinpointing where long SQL calls originate from.
150 | stack_trace_threshold: 0.500
151 |
152 | # Determines whether the agent will capture query plans for slow
153 | # SQL queries. Only supported in mysql and postgres. Should be
154 | # set to false when using other adapters.
155 | # explain_enabled: true
156 |
157 | # Threshold for query execution time below which query plans will
158 | # not be captured. Relevant only when `explain_enabled` is true.
159 | # explain_threshold: 0.5
160 |
161 | # Error collector captures information about uncaught exceptions and
162 | # sends them to New Relic for viewing
163 | error_collector:
164 |
165 | # Error collector is enabled by default. Set this to false to turn
166 | # it off. This feature is only available at the Professional and above
167 | # product levels.
168 | enabled: true
169 |
170 | # To stop specific errors from reporting to New Relic, set this property
171 | # to comma-separated values. Default is to ignore routing errors,
172 | # which are how 404's get triggered.
173 | ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
174 |
175 | # If you're interested in capturing memcache keys as though they
176 | # were SQL uncomment this flag. Note that this does increase
177 | # overhead slightly on every memcached call, and can have security
178 | # implications if your memcached keys are sensitive
179 | # capture_memcache_keys: true
180 |
181 | # Application Environments
182 | # ------------------------------------------
183 | # Environment-specific settings are in this section.
184 | # For Rails applications, RAILS_ENV is used to determine the environment.
185 | # For Java applications, pass -Dnewrelic.environment to set
186 | # the environment.
187 |
188 | # NOTE if your application has other named environments, you should
189 | # provide newrelic configuration settings for these environments here.
190 |
191 | development:
192 | <<: *default_settings
193 | # Turn on communication to New Relic service in development mode
194 | monitor_mode: true
195 | app_name: Rails and Flux (Development)
196 |
197 | # Rails Only - when running in Developer Mode, the New Relic Agent will
198 | # present performance information on the last 100 transactions you have
199 | # executed since starting the mongrel.
200 | # NOTE: There is substantial overhead when running in developer mode.
201 | # Do not use for production or load testing.
202 | developer_mode: true
203 |
204 | test:
205 | <<: *default_settings
206 | # It almost never makes sense to turn on the agent when running
207 | # unit, functional or integration tests or the like.
208 | monitor_mode: false
209 |
210 | # Turn on the agent in production for 24x7 monitoring. NewRelic
211 | # testing shows an average performance impact of < 5 ms per
212 | # transaction, you can leave this on all the time without
213 | # incurring any user-visible performance degradation.
214 | production:
215 | <<: *default_settings
216 | monitor_mode: true
217 |
218 | # Many applications have a staging environment which behaves
219 | # identically to production. Support for that environment is provided
220 | # here. By default, the staging environment has the agent turned on.
221 | staging:
222 | <<: *default_settings
223 | monitor_mode: true
224 | app_name: Rails and Flux (Staging)
225 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | root 'home#index'
3 |
4 |
5 | namespace :api do
6 | namespace :v1 do
7 | resources :people, only: [:index, :show]
8 | end
9 | end
10 |
11 | get '*path', to: 'home#index'
12 |
13 | # The priority is based upon order of creation: first created -> highest priority.
14 | # See how all your routes lay out with "rake routes".
15 |
16 | # You can have the root of your site routed with "root"
17 | # root 'welcome#index'
18 |
19 | # Example of regular route:
20 | # get 'products/:id' => 'catalog#view'
21 |
22 | # Example of named route that can be invoked with purchase_url(id: product.id)
23 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
24 |
25 | # Example resource route (maps HTTP verbs to controller actions automatically):
26 | # resources :products
27 |
28 | # Example resource route with options:
29 | # resources :products do
30 | # member do
31 | # get 'short'
32 | # post 'toggle'
33 | # end
34 | #
35 | # collection do
36 | # get 'sold'
37 | # end
38 | # end
39 |
40 | # Example resource route with sub-resources:
41 | # resources :products do
42 | # resources :comments, :sales
43 | # resource :seller
44 | # end
45 |
46 | # Example resource route with more complex sub-resources:
47 | # resources :products do
48 | # resources :comments
49 | # resources :sales do
50 | # get 'recent', on: :collection
51 | # end
52 | # end
53 |
54 | # Example resource route with concerns:
55 | # concern :toggleable do
56 | # post 'toggle'
57 | # end
58 | # resources :posts, concerns: :toggleable
59 | # resources :photos, concerns: :toggleable
60 |
61 | # Example resource route within a namespace:
62 | # namespace :admin do
63 | # # Directs /admin/products/* to Admin::ProductsController
64 | # # (app/controllers/admin/products_controller.rb)
65 | # resources :products
66 | # end
67 | end
68 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 3cef6a599347dc5162dff9946ff99160aff00d14033244f9dd80848b2b5a9a395c3e0ea989203519af9e7eb79f0e86c6e2d0f0d8a6a1ddb52b4ae42a1e1cd391
15 | google_analytics_id: foo
16 |
17 | test:
18 | secret_key_base: 91e0134c84aa381b0d80b154ad1604cd43d84edce05ce1c9bb9bc4e5c387e58a59491acd724e7fed412c13f5191ea6566ffdf77806a3a4258f403b6f59fc878c
19 | google_analytics_id: foo
20 |
21 | # Do not keep production secrets in the repository,
22 | # instead read values from the environment.
23 | production:
24 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
25 | google_analytics_id: <%= ENV["GOOGLE_ANALYTICS_ID"] %>
26 |
--------------------------------------------------------------------------------
/db/migrate/20140905152314_create_people.rb:
--------------------------------------------------------------------------------
1 | class CreatePeople < ActiveRecord::Migration
2 | def change
3 | create_table :people do |t|
4 | t.string :first_name, null: false
5 | t.string :last_name
6 | t.integer :gender, default: 0
7 | t.date :birth_date
8 | t.string :location
9 | t.string :phone_number
10 | t.string :email
11 | t.text :headline
12 |
13 | t.timestamps null: false
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20140905154625_add_picture_to_people.rb:
--------------------------------------------------------------------------------
1 | class AddPictureToPeople < ActiveRecord::Migration
2 | def change
3 | add_column :people, :picture, :string, after: :headline
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | # This file is auto-generated from the current state of the database. Instead
3 | # of editing this file, please use the migrations feature of Active Record to
4 | # incrementally modify your database, and then regenerate this schema definition.
5 | #
6 | # Note that this schema.rb definition is the authoritative source for your
7 | # database schema. If you need to create the application database on another
8 | # system, you should be using db:schema:load, not running all the migrations
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 | # you'll amass, the slower it'll run and the greater likelihood for issues).
11 | #
12 | # It's strongly recommended that you check this file into your version control system.
13 |
14 | ActiveRecord::Schema.define(version: 20140905154625) do
15 |
16 | # These are extensions that must be enabled in order to support this database
17 | enable_extension "plpgsql"
18 |
19 | create_table "people", force: true do |t|
20 | t.string "first_name", null: false
21 | t.string "last_name"
22 | t.integer "gender", default: 0
23 | t.date "birth_date"
24 | t.string "location"
25 | t.string "phone_number"
26 | t.string "email"
27 | t.text "headline"
28 | t.datetime "created_at", null: false
29 | t.datetime "updated_at", null: false
30 | t.string "picture"
31 | end
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | 50.times do |i|
2 | Person.create do |person|
3 | first_name = Faker::Name.first_name
4 | gender = Person.genders.values.sample
5 | picture_gender = gender == Person.genders[:male] ? 'men' : 'women'
6 |
7 | person.first_name = first_name
8 | person.last_name = Faker::Name.last_name
9 | person.gender = gender
10 | person.birth_date = (20..40).to_a.sample.years.ago
11 | person.location = Faker::Address.country
12 | person.email = Faker::Internet.email(first_name)
13 | person.phone_number = Faker::PhoneNumber.cell_phone
14 | person.headline = Faker::Lorem.sentence(3, true)
15 | person.picture = "http://api.randomuser.me/portraits/#{picture_gender}/#{i}.jpg"
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/lib/tasks/.keep
--------------------------------------------------------------------------------
/lib/tasks/auto_annotate_models.rake:
--------------------------------------------------------------------------------
1 | # NOTE: only doing this in development as some production environments (Heroku)
2 | # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3 | # NOTE: to have a dev-mode tool do its thing in production.
4 | if Rails.env.development?
5 | task :set_annotation_options do
6 | # You can override any of these by setting an environment variable of the
7 | # same name.
8 | Annotate.set_defaults({
9 | 'position_in_routes' => "before",
10 | 'position_in_class' => "before",
11 | 'position_in_test' => "before",
12 | 'position_in_fixture' => "before",
13 | 'position_in_factory' => "before",
14 | 'show_indexes' => "true",
15 | 'simple_indexes' => "false",
16 | 'model_dir' => "app/models",
17 | 'include_version' => "false",
18 | 'require' => "",
19 | 'exclude_tests' => "false",
20 | 'exclude_fixtures' => "false",
21 | 'exclude_factories' => "false",
22 | 'ignore_model_sub_dir' => "false",
23 | 'skip_on_db_migrate' => "false",
24 | 'format_bare' => "true",
25 | 'format_rdoc' => "false",
26 | 'format_markdown' => "false",
27 | 'sort' => "false",
28 | 'force' => "false",
29 | 'trace' => "false",
30 | })
31 | end
32 |
33 | Annotate.load_tasks
34 | end
35 |
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigardone/rails_and_redux/66010a99f4e41bcee1737043adcbab7ad2485e6d/log/.keep
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rails_and_redux",
3 | "scripts": {
4 | "start": "./node_modules/.bin/webpack --progress --colors --watch"
5 | },
6 | "devDependencies": {
7 | "webpack": "~1.7.3",
8 | "jsx-loader": "~0.12.2",
9 | "cjsx-loader": "~2.0.1",
10 | "coffee-loader": "^0.7.2",
11 | "babel-loader": "^4.2.0"
12 | },
13 | "dependencies": {
14 | "classnames": "1.2.0",
15 | "history": "^1.9.1",
16 | "isomorphic-fetch": "^2.1.1",
17 | "lodash": "^3.10.1",
18 | "moment": "^2.10.3",
19 | "react": "^0.14.0",
20 | "react-dom": "^0.14.0",
21 | "react-redux": "^2.1.1",
22 | "react-router": "1.0.0-rc1",
23 | "redux-logger": "^1.0.6",
24 | "redux-thunk": "^0.1.0"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.