From 10cf40e3587895363f7e2c869da5f9d9cd66e471 Mon Sep 17 00:00:00 2001 From: yafeilee Date: Wed, 25 Feb 2015 13:30:43 +0800 Subject: [PATCH] add cors --- Gemfile | 1 + Gemfile.lock | 2 ++ app/views/home/mobile.html.slim | 6 +++--- config/environments/development.rb | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 03b91d3..78facc9 100644 --- a/Gemfile +++ b/Gemfile @@ -43,6 +43,7 @@ group :development do gem 'guard-rails' gem 'guard-rspec', require: false gem 'guard-bundler', require: false + gem 'rack-cors', :require => 'rack/cors' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index f398ae4..74f7186 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,6 +170,7 @@ GEM quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.5.2) + rack-cors (0.3.1) rack-test (0.6.3) rack (>= 1.0) rails (4.1.8) @@ -317,6 +318,7 @@ DEPENDENCIES pry-nav pry-rails quiet_assets + rack-cors rails (= 4.1.8) redcarpet rest-client diff --git a/app/views/home/mobile.html.slim b/app/views/home/mobile.html.slim index 5994ce9..891b7cf 100644 --- a/app/views/home/mobile.html.slim +++ b/app/views/home/mobile.html.slim @@ -9,7 +9,7 @@ p | 这是一个拥有独立思想的技术达人的交流分享的地方. p - | 我曾经在深信服工作大约 5 年. 在那里, 从一个菜鸟成长为一个资深工程师, 还有幸带领一个很酷的团队帮助公司进行自动化测试方向的研究与推进. + | 我曾经在深信服工作大约 5 年. 在那里, 从一个菜鸟成长为一个资深工程师, 还有幸带领一个很酷的团队帮助公司进行自动化测试方向的研究与推进. p | 在 2014 年 3 月份, 为了那份创业梦, 开发了 http://cywin.cn, 这是一个股权众筹平台, 帮助创业团队更好的融资. 借此, 也将自己的 Ruby on Rails 技术全部注入在内. p @@ -50,5 +50,5 @@ | 版权说明 .item.item-text-wrap p - | WBlog 是我亲手一行行写出来的, 开源可复用, 采用协议 MIT, 你可以在 Github 上找到它: - a href='https://github.com/windy/wblog' target='_blank' https://github.com/windy/wblog + | WBlog 是我亲手一行行写出来的, 开源可复用, 采用协议 MIT, 你可以在 Github 上找到它: + a href='https://github.com/windy/wblog' target='_blank' location='yes' https://github.com/windy/wblog diff --git a/config/environments/development.rb b/config/environments/development.rb index 162d6e8..9817503 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -24,6 +24,13 @@ WBlog::Application.configure do # number of complex assets. config.assets.debug = true + config.middleware.insert_before 0, "Rack::Cors" do + allow do + origins '*' + resource '*', :headers => :any, :methods => [:get, :post, :options] + end + end + config.action_mailer.default_url_options = { :host => 'localhost:3000' } config.action_mailer.smtp_settings = {