Stream of Ry

Yet Another Geek In The World

How to get out of debt by Dave Ramsey

leave a comment>>

I’m keeping this here as a reminder to myself:

  1. $1000 Emergency Fund
  2. Debt snowball: Start from the small ones
  3. 3 to 6 months of expenses in savings
  4. Invest 15% of income
  5. *College fund
  6. *Mortgage fund
  7. Share

* doesn’t really apply to me yet

You can find out more from his website:

 

Written by rystraum

February 2nd, 2012 at 3:36 pm

Posted in Uncategorized

2 days 1 line: devise_for in different constraints

leave a comment>>

Here’s an e-mail I sent to the Devise mailing list:

Hi,

I patterned my app to this: https://github.com/RailsApps/rails3-subdomains but using AR instead of Mongoid.
I’m trying to extend it such that a user can log in inside a subdomain and at the main area and different classes will handle sessions/registrations in each context.

Here’s my routes:

  constraints(Subdomain) do
    scope :module => "brand" do
      devise_for :subscribers, :class_name => "User", :module => "brand/devise"
      match "/dashboard" => "subscribers#dashboard"
      match '/' => 'home#index'
    end
  end

  devise_for :subscribers, :class_name => "User"

If I remove the 2nd devise_for, it works in the subdomains but I can’t log in the main domain.

Edit: I partially solved my problem while typing out this mail. Will send it still just in case it helps someone.

Partially, in the sense that I can log in at the subdomain and in the main domain but only Brand::Devise controllers handle both cases.

Changing the routes to this fixed it:

  constraints(Subdomain) do
    scope :module => "brand" do
      match "/dashboard" => "subscribers#dashboard"
      match '/' => 'home#index'
    end
  end

  devise_for :subscribers, :class_name => "User", :module => "brand/devise"

Apparently, you can only specify the same resource (:subscribers in this case) only once and the latest call to devise_for will be the one that will apply, regardless if it is within a constraint or not. My motivations in maintaining the resource is to keep my controllers/views dry.

I’m guessing that putting in different resource names will work. It might become confusing though.

2 days of wracking my brains on this and I only had to move a line out of a block. The joys of programming. Haha.

Rystraum

Written by rystraum

February 1st, 2012 at 7:00 pm

Posted in Uncategorized

Full Calendar

leave a comment>>

Full Calendar

Written by Stream of Ry

January 29th, 2012 at 7:31 pm

Posted in Uncategorized

Table Sorter

leave a comment>>

Table Sorter

Written by Stream of Ry

January 29th, 2012 at 7:30 pm

Posted in Uncategorized

Implementation Intentions

leave a comment>>

Implementation Intentions

Written by Stream of Ry

January 29th, 2012 at 12:17 pm

Posted in Uncategorized