Ruby on Rails

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentRuby on Rails

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 25th, 2011, 01:23 PM
clem_c_rock clem_c_rock is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 33 clem_c_rock New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
Problem w/ routing constraints

Hello,
I am having a strange problem w/ rails 3 routing constraints. I
have this custom class w/ a self.matches? method as such:

Code:

class PersonalizedDomain

  def self.matches?(request)
    Rails.logger.info("self.matches? NEVER CALLED!!!!")
  end



and in routes I use the custom Class like this:

Code:
require 'personalized_domain' #resides in lib

  constraints(PersonalizedDomain) do

     Rails.logger.info("constraints block ENTERED")
      root :to => "projects#show"
  end



and in application.rb, I load my lib paths:

Code:
config.autoload_paths += %W(#{config.root}/lib)



The self.matches?(request) method never gets called and I don't
understand why?

Last edited by clem_c_rock : April 25th, 2011 at 07:54 PM.

Reply With Quote
  #2  
Old April 29th, 2011, 10:54 AM
clem_c_rock clem_c_rock is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 33 clem_c_rock New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
SOLUTION: Here's an update - I did figure out why my custom constraint wasn't working correctly and here's the changes I made:

In PersonalizedDomain I changed the self.matches? method from a class method to an instance method as such:

Code:
# lib/personalized_domain.rb
class PersonalizedDomain
  def matches?(request)
    case request.host
    when "www.#{APP_CONFIG[:domain]}", "#{APP_CONFIG[:domain]}", nil
      false
    else
      true
    end
  end
end


and in routes I did this:

Code:
constraints(PersonalizedDomain.new) do
      resources :posts
      resources :personalized
  end

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentRuby on Rails > Problem w/ routing constraints


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap