upgrade to rails v4.0.2

This commit is contained in:
Serge Paquet 2013-12-30 17:29:00 -05:00
父節點 8a76402c1b
當前提交 9b0294c471
共有 28 個檔案被更改,包括 185 行新增201 行删除

7
.gitignore vendored
查看文件

@ -1,14 +1,15 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/db/sphinx
# Ignore all logfiles and tempfiles.

23
Gemfile
查看文件

@ -1,26 +1,29 @@
source "https://rubygems.org"
gem "rails", "3.2.16"
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
gem "rails", "4.0.2"
gem "rake", "10.0.3"
# Use mysql2 as the database for Active Record
gem "mysql2", ">= 0.3.14"
# Bundle edge Rails instead:
# gem "rails", :git => "git://github.com/rails/rails.git"
# Use Rails3-style mass assignment security
gem "protected_attributes"
gem "mysql2", :git => "git://github.com/brianmario/mysql2.git"
gem "bcrypt-ruby", "3.0.0"
# Use Uglifier as compressor for JavaScript assets
gem "uglifier", ">= 1.3.0"
# Use jquery as the JavaScript library
gem "jquery-rails"
gem "dynamic_form"
# use old version that doesn't have tinder bullshit
gem "exception_notification", "2.6.1"
gem "unicorn"
# Use ActiveModel has_secure_password
gem "bcrypt-ruby", "~> 3.1.2"
# for asset compilation
gem "uglifier"
# Use unicorn as the app server
gem "unicorn"
gem "nokogiri"
gem "htmlentities"

查看文件

@ -1,42 +1,34 @@
GIT
remote: git://github.com/brianmario/mysql2.git
revision: a9787cbb88f18d12f0b5c370c519d077ad68c862
specs:
mysql2 (0.3.14)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.16)
actionpack (= 3.2.16)
actionmailer (4.0.2)
actionpack (= 4.0.2)
mail (~> 2.5.4)
actionpack (3.2.16)
activemodel (= 3.2.16)
activesupport (= 3.2.16)
builder (~> 3.0.0)
actionpack (4.0.2)
activesupport (= 4.0.2)
builder (~> 3.1.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.16)
activesupport (= 3.2.16)
builder (~> 3.0.0)
activerecord (3.2.16)
activemodel (= 3.2.16)
activesupport (= 3.2.16)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.16)
activemodel (= 3.2.16)
activesupport (= 3.2.16)
activesupport (3.2.16)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.2)
activesupport (= 4.0.2)
builder (~> 3.1.0)
activerecord (4.0.2)
activemodel (= 4.0.2)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.2)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.2)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
bcrypt-ruby (3.0.0)
builder (3.0.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.1)
atomic (1.1.14)
bcrypt-ruby (3.1.2)
builder (3.1.4)
diff-lcs (1.2.5)
dynamic_form (1.1.4)
erubis (2.7.0)
@ -45,8 +37,7 @@ GEM
execjs (2.0.2)
hike (1.2.3)
htmlentities (4.3.1)
i18n (0.6.8)
journey (1.0.4)
i18n (0.6.9)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
@ -58,38 +49,34 @@ GEM
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.8.2)
nokogiri (1.6.0)
mysql2 (0.3.14)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
oauth (0.4.7)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
protected_attributes (1.0.5)
activemodel (>= 4.0.1, < 5.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.16)
actionmailer (= 3.2.16)
actionpack (= 3.2.16)
activerecord (= 3.2.16)
activeresource (= 3.2.16)
activesupport (= 3.2.16)
bundler (~> 1.0)
railties (= 3.2.16)
railties (3.2.16)
actionpack (= 3.2.16)
activesupport (= 3.2.16)
rack-ssl (~> 1.3.2)
rails (4.0.2)
actionmailer (= 4.0.2)
actionpack (= 4.0.2)
activerecord (= 4.0.2)
activesupport (= 4.0.2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.2)
sprockets-rails (~> 2.0.0)
railties (4.0.2)
actionpack (= 4.0.2)
activesupport (= 4.0.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
thor (>= 0.18.1, < 2.0)
raindrops (0.12.0)
rake (10.0.3)
rake (10.1.1)
rdiscount (2.1.7)
rdoc (3.12.2)
json (~> 1.4)
riddle (1.5.9)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
@ -102,23 +89,29 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sprockets (2.2.2)
sprockets (2.10.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
thinking-sphinx (2.0.12)
activerecord (>= 3.0.3)
builder (>= 2.1.2)
riddle (>= 1.5.2)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
uglifier (2.3.2)
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.7.0)
@ -130,21 +123,21 @@ PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby (= 3.0.0)
bcrypt-ruby (~> 3.1.2)
dynamic_form
exception_notification (= 2.6.1)
htmlentities
jquery-rails
machinist
mail
mysql2!
mysql2 (>= 0.3.14)
nokogiri
oauth
rails (= 3.2.16)
rake (= 10.0.3)
protected_attributes
rails (= 4.0.2)
rdiscount
rspec-rails (~> 2.6)
sqlite3
thinking-sphinx (= 2.0.12)
uglifier
uglifier (>= 1.3.0)
unicorn

查看文件

@ -1,4 +1,3 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

查看文件

@ -196,7 +196,7 @@ private
(@page - 1) * STORIES_PER_PAGE
).order(
newest ? "stories.created_at DESC" : "hotness"
)
).to_a
show_more = false

查看文件

@ -1,7 +1,6 @@
class Story < ActiveRecord::Base
belongs_to :user
has_many :taggings,
:include => :tag,
:autosave => true
has_many :comments
has_many :tags, :through => :taggings

查看文件

@ -1,6 +1,6 @@
class User < ActiveRecord::Base
has_many :stories,
:include => :user
-> { includes :user }
has_many :comments
has_many :sent_messages,
:class_name => "Message",

3
bin/bundle Executable file
查看文件

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
bin/rails Executable file
查看文件

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
bin/rake Executable file
查看文件

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

查看文件

@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Lobsters::Application
run Rails.application

查看文件

@ -2,12 +2,9 @@ require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module Lobsters
class Application < Rails::Application
@ -18,13 +15,6 @@ module Lobsters
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Central Time (US & Canada)'
@ -33,28 +23,14 @@ module Lobsters
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Future Rails version will disable implicit joins, so we'll be prepared.
config.active_record.disable_implicit_join_references = true
config.cache_store = :memory_store
end

查看文件

@ -1,5 +1,3 @@
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

查看文件

@ -1,5 +1,5 @@
# Load the rails application
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the rails application
# Initialize the Rails application.
Lobsters::Application.initialize!

查看文件

@ -1,37 +1,32 @@
Lobsters::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
end

查看文件

@ -1,67 +1,80 @@
Lobsters::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests
# Code is not reloaded between requests.
config.cache_classes = true
# Full error reports are disabled and caching is turned on
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# fallback to assets pipeline if a precompiled asset is missed
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs
# Generate digests for assets URLs.
config.assets.digest = true
# Defaults to Rails.root.join("public/assets")
# config.assets.manifest = YOUR_PATH
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end

查看文件

@ -1,5 +1,5 @@
Lobsters::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@ -7,31 +7,33 @@ Lobsters::Application.configure do
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Raise exception on mass assignment protection for Active Record models
# Raise exception on mass assignment protection for Active Record models.
config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
end

查看文件

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

查看文件

@ -1,15 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
#
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections do |inflect|
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

查看文件

@ -2,8 +2,3 @@
Lobsters::Application.config.session_store :cookie_store,
key: 'lobster_trap', expire_after: 1.month
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# Lobsters::Application.config.session_store :active_record_store

查看文件

@ -1,14 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# Disable root element in JSON by default.
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

查看文件

@ -23,15 +23,15 @@ Lobsters::Application.routes.draw do
post "/signup" => "signup#signup"
get "/signup/invite" => "signup#invite"
match "/login/forgot_password" => "login#forgot_password",
get "/login/forgot_password" => "login#forgot_password",
:as => "forgot_password"
post "/login/reset_password" => "login#reset_password",
:as => "reset_password"
match "/login/set_new_password" => "login#set_new_password",
:as => "set_new_password"
:as => "set_new_password", :via => [:get, :post]
match "/t/:tag" => "home#tagged", :as => "tag"
match "/t/:tag/page/:page" => "home#tagged"
get "/t/:tag" => "home#tagged", :as => "tag"
get "/t/:tag/page/:page" => "home#tagged"
get "/search" => "search#index"

查看文件

@ -4,7 +4,7 @@ class CreateInvitations < ActiveRecord::Migration
t.integer :user_id
t.string :email
t.string :code
t.timestamps
t.timestamps :null => false
end
add_column :users, :invited_by_user_id, :integer

查看文件

@ -1,7 +1,7 @@
class UserFilter < ActiveRecord::Migration
def up
create_table :tag_filters do |t|
t.timestamps
t.timestamps :null => false
t.integer :user_id
t.integer :tag_id
end

查看文件

@ -3,7 +3,7 @@ class AddModerationLog < ActiveRecord::Migration
add_column "users", "is_moderator", :boolean, :default => false
create_table "moderations" do |t|
t.timestamps
t.timestamps :null => false
t.integer "moderator_user_id"
t.integer "story_id"
t.integer "comment_id"

查看文件

@ -7,7 +7,7 @@ class AddInvitationRequests < ActiveRecord::Migration
t.string :name
t.text :memo
t.string :ip_address
t.timestamps
t.timestamps :null => false
end
end

查看文件

@ -1,6 +0,0 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'