Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Gemify #1

Closed
wants to merge 6 commits into from

2 participants

@yyyc514

Try and freshen this up a bit considering Rails 3.2 is about to depreciate plugins but this is still useful.

@yyyc514

Ping.

@yyyc514

Ping. Can we please merge?

@yyyc514

Ping.

@rafaelfranca

Hi, sorry for the delay. This plugin is deprecated and we don't accept issues or PR. If you want we can point this repository to your fork. Let me know if you want we to change the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 6, 2012
  1. @yyyc514

    add gemspec

    yyyc514 authored
  2. @yyyc514
  3. @yyyc514
Commits on Jan 29, 2013
  1. @yyyc514

    rename to markdown

    yyyc514 authored
  2. @yyyc514
Commits on Jan 30, 2013
  1. @yyyc514
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -0,0 +1,2 @@
+account_location-*.gem
+rails_account_location-*.gem
View
1  Gemfile
@@ -0,0 +1 @@
+source :rubygems
View
30 lib/account_location.rb → MIT-LICENSE
@@ -18,33 +18,3 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-module AccountLocation
- def self.included(controller)
- controller.helper_method(:account_domain, :account_subdomain, :account_host, :account_url)
- end
-
- protected
- def default_account_subdomain
- @account.username if @account && @account.respond_to?(:username)
- end
-
- def account_url(account_subdomain = default_account_subdomain, use_ssl = request.ssl?)
- (use_ssl ? "https://" : "http://") + account_host(account_subdomain)
- end
-
- def account_host(account_subdomain = default_account_subdomain)
- account_host = ""
- account_host << account_subdomain + "."
- account_host << account_domain
- end
-
- def account_domain
- account_domain = ""
- account_domain << request.subdomains[1..-1].join(".") + "." if request.subdomains.size > 1
- account_domain << request.domain + request.port_string
- end
-
- def account_subdomain
- request.subdomains.first
- end
-end
View
48 README
@@ -1,48 +0,0 @@
-Account Location
-================
-
-Account location is a set of protected methods that supports the account-key-as-subdomain
-way of identifying the current scope. These methods allow you to easily produce URLs that
-match this style and to get the current account key from the subdomain.
-
-The methods are: account_url, account_host, and account_domain.
-
-Example:
-
- class ApplicationController < ActionController::Base
- include AccountLocation
- before_filter :find_account
-
- protected
- def find_account
- @account = Account.find_by_username(account_subdomain)
- end
- end
-
- class AccountController < ApplicationController
- def new
- @new_account = Account.create(params[:new_account])
- redirect_to :host => account_host(@new_account.username), :controller => "weblog"
- end
-
- def authenticate
- session[account_domain] = :authenticated
- redirect_to :controller => "weblog"
- end
-
- protected
- def authenticated?
- session[account_domain] == :authenticated
- end
- end
-
- # The view:
-
- Your domain: <%= account_url %>
-
-By default, all the methods will query for @account.username as the account key, but you can
-specialize that by overwriting default_account_subdomain. You can of course also pass it in
-as the first argument to all the methods.
-
-
-Copyright (c) 2005 David Heinemeier Hansson, released under the MIT license
View
57 README.md
@@ -0,0 +1,57 @@
+Account Location
+================
+
+Account location is a set of protected methods that supports the account-key-as-subdomain
+way of identifying the current scope. These methods allow you to easily produce URLs that
+match this style and to get the current account key from the subdomain.
+
+The methods are: `account_url`, `account_host`, and `account_domain`.
+
+current_account can be used to get and set the currently active account.
+
+
+Example:
+
+ class ApplicationController < ActionController::Base
+ include AccountLocation
+ before_filter :find_account
+
+ protected
+ def find_account
+ self.current_account = Account.find_by_username(account_subdomain)
+ end
+ end
+
+ class UsersController < ApplicationController
+ def index
+ @users = current_account.users.all
+ end
+ end
+
+ class AccountController < ApplicationController
+ def new
+ @new_account = Account.create(params[:new_account])
+ redirect_to :host => account_host(@new_account.username), :controller => "weblog"
+ end
+
+ def authenticate
+ session[account_domain] = :authenticated
+ redirect_to :controller => "weblog"
+ end
+
+ protected
+ def authenticated?
+ session[account_domain] == :authenticated
+ end
+ end
+
+And in your view:
+
+ Your domain: <%= account_url %>
+
+By default, all the methods will query for current_account.username as the account key, but you can
+specialize that by overwriting default_account_subdomain. You can of course also pass it in
+as the first argument to all the methods.
+
+
+Copyright (c) 2005 David Heinemeier Hansson, released under the MIT license
View
26 account_location.gemspec
@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+
+$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
+
+version = "1.0.1"
+
+Gem::Specification.new do |s|
+ s.name = "rails_account_location"
+ s.version = version
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["David Heinemeier Hansson"]
+ s.email = "david@37signals.com"
+ s.homepage = "http://github.com/rails/account_location"
+ s.summary = "Module that supports account-key-as-subdomain pattern"
+ s.description = "Account location is a set of protected methods that supports the account-key-as-subdomain way of identifying the current scope."
+
+ s.rubygems_version = "1.3.7"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
+ s.extra_rdoc_files = [ "README.md" ]
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_path = "lib"
+
+ s.add_runtime_dependency "rails"
+end
View
41 lib/rails_account_location.rb
@@ -0,0 +1,41 @@
+module AccountLocation
+ def self.included(controller)
+ controller.helper_method(:account_domain, :account_subdomain, :account_host, :account_url,
+ :current_account)
+ end
+
+ protected
+
+ def current_account
+ @current_account
+ end
+
+ def current_account=(account)
+ @current_account = account
+ end
+
+ def default_account_subdomain
+ account = current_account || @account
+ account.username if account && account.respond_to?(:username)
+ end
+
+ def account_url(account_subdomain = default_account_subdomain, use_ssl = request.ssl?)
+ (use_ssl ? "https://" : "http://") + account_host(account_subdomain)
+ end
+
+ def account_host(account_subdomain = default_account_subdomain)
+ account_host = ""
+ account_host << account_subdomain + "."
+ account_host << account_domain
+ end
+
+ def account_domain
+ account_domain = ""
+ account_domain << request.subdomains[1..-1].join(".") + "." if request.subdomains.size > 1
+ account_domain << request.domain + request.port_string
+ end
+
+ def account_subdomain
+ request.subdomains.first
+ end
+end
Something went wrong with that request. Please try again.