Anthony Baker (ThinkBigIdeas)
2005-Apr-03 15:52 UTC
Evangelizing Ruby and Rails to Hosting Providers
Hey Folks, Forgive me in advance if this is a discussion already had. While I am going to be shortly setting up an account with TextDrive (and am happy to support that), my current primary host -- for my site, as well as customer sites -- is Dreamhost. Previous to that was Media Temple, but Dreamhost had a package and price that MT couldn''t match. Already sent email to the DH folks trying to evangelize Ruby and Rails (they''re not, at least when I last checked, currently keeping the latest-and-greatest Ruby updates and don''t actively support Rails), but was turned down. They said there just wasn''t enough interest yet. I countered with them, pointing to the developer buzz on both Ruby and Rails, as well as some other stats, but no dice. Anyone had any success with other larger hosting providers in advocating the combo? Would love to be able to come up with some way that works to have R&R adopted and maintained in much the same way that PHP/MySQL is these days. Thanks, Anthony
I don''t think its your job to help out providers get their act together. Not enough interest is just another way of saying that they don''t care enough and ignore a great opportunity to have an competitive edge over other hosts even though they have been informed about the matter. If they can''t offer the technology you need its probably a good time to look for someone who does. There are three options you have: * Install ruby and rails in your home dir, this will require that they at least let you use fastcgi to get reasonable performance * Move to a rails friendly host like textdrive * Get a (virtual-) server on which you have root and be your own provider. On Apr 3, 2005 11:52 AM, ThinkBigIdeas Anthony Baker <anthony-ZEJemHc0OvwkEFqJWa3iIgC/G2K4zDHf@public.gmane.org> wrote:> Hey Folks, > > Forgive me in advance if this is a discussion already had. > > While I am going to be shortly setting up an account with TextDrive > (and am happy to support that), my current primary host -- for my site, > as well as customer sites -- is Dreamhost. Previous to that was Media > Temple, but Dreamhost had a package and price that MT couldn''t match. > > Already sent email to the DH folks trying to evangelize Ruby and Rails > (they''re not, at least when I last checked, currently keeping the > latest-and-greatest Ruby updates and don''t actively support Rails), but > was turned down. They said there just wasn''t enough interest yet. I > countered with them, pointing to the developer buzz on both Ruby and > Rails, as well as some other stats, but no dice. > > Anyone had any success with other larger hosting providers in > advocating the combo? Would love to be able to come up with some way > that works to have R&R adopted and maintained in much the same way that > PHP/MySQL is these days. > > Thanks, > > Anthony > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
On Sun, 3 Apr 2005, Anthony Baker wrote:> Anyone had any success with other larger hosting providers in advocating the > combo? Would love to be able to come up with some way that works to have R&R > adopted and maintained in much the same way that PHP/MySQL is these days.I suggest going to a place that will give you a virtual machine, such as jvds.net. Their answer when you ask for Rails to be installed will be something like "here''s your root password, have a nice day". -- Matt Nothing great was ever accomplished without _passion_
I thought this would be really simple but the docs do not seem to cover it. I need to create routing rules based on my subdomain. I have wap.mydomain.com. When users access this URL, they should get redirected to a different controller. I have subclassed some of my controllers, so for instance I have WapListItemsController < ListItemsController. This way I can have separate views/layouts and, if necessary, separate controller logic (though so far, the controller logic is just inherited from the parent). Right now I have a default rule like: map.connect '''', :controller => ''list_items'', :action => ''show'' I want something that would work like: map.connect subdomain(''wap''), :controller => ''wap_list_items'', :action => ''show'' Any ideas?
Jeremy Huffman wrote:> I thought this would be really simple but the docs do not seem to cover > it. I need to create routing rules based on my subdomain. > > I have wap.mydomain.com. When users access this URL, they should get > redirected to a different controller. I have subclassed some of my > controllers, so for instance I have WapListItemsController < > ListItemsController. > > This way I can have separate views/layouts and, if necessary, separate > controller logic (though so far, the controller logic is just inherited > from the parent). > > Right now I have a default rule like: > > map.connect '''', :controller => ''list_items'', :action => ''show'' > > I want something that would work like: > > map.connect subdomain(''wap''), :controller => ''wap_list_items'', :action > => ''show'' > > Any ideas?Routes only map the URI path for now, so you can''t route based on scheme, host, port, query string, etc. You can use a before_filter to check whether you''re in a subdomain, but by then the controller''s already chosen so they best you can do is set something like @client_type = ''wap'' and check for it in your actions. You could also get fancy and delegate to a wap_* action if it exists: before_filter :check_for_client_specific_action protected attr_reader :client_type def check_for_client_specific_action # Determine client type from request subdomain. @client_type = @request.subdomains.first || ''www'' # Change action on the fly if a specialized action exists. client_specific_action = "#{client_type}_#{action_name}" if action_methods.include?(client_specific_action) @params[''action''] = client_specific_action end end public def show render_text "show me at #{@request.host}" end def wap_show render_text "wappinate me at #{@request.host}" end A solution using Routes would be much nicer. jeremy
Jeremy Kemper wrote:>Jeremy Huffman wrote: > > >>I thought this would be really simple but the docs do not seem to cover >>it. I need to create routing rules based on my subdomain. >> >>I have wap.mydomain.com. When users access this URL, they should get >>redirected to a different controller. I have subclassed some of my >>controllers, so for instance I have WapListItemsController < >>ListItemsController. >> >>This way I can have separate views/layouts and, if necessary, separate >>controller logic (though so far, the controller logic is just inherited >>from the parent). >> >>Right now I have a default rule like: >> >> map.connect '''', :controller => ''list_items'', :action => ''show'' >> >>I want something that would work like: >> >> map.connect subdomain(''wap''), :controller => ''wap_list_items'', :action >>=> ''show'' >> >>Any ideas? >> >> > >Routes only map the URI path for now, so you can''t route based on >scheme, host, port, query string, etc. > >You can use a before_filter to check whether you''re in a subdomain, but >by then the controller''s already chosen so they best you can do is set >something like @client_type = ''wap'' and check for it in your actions. > >You could also get fancy and delegate to a wap_* action if it exists: > >before_filter :check_for_client_specific_action > >protected > attr_reader :client_type > > def check_for_client_specific_action > # Determine client type from request subdomain. > @client_type = @request.subdomains.first || ''www'' > > # Change action on the fly if a specialized action exists. > client_specific_action = "#{client_type}_#{action_name}" > if action_methods.include?(client_specific_action) > @params[''action''] = client_specific_action > end > end > >public > def show > render_text "show me at #{@request.host}" > end > > def wap_show > render_text "wappinate me at #{@request.host}" > end > > >A solution using Routes would be much nicer. > > >Yeah, I agree. I pretty much am convinced that I need different controllers though. I''m subclassing my controller - this way, I can reuse my existing action''s code but will automatically render different views. If I need to override the actions I can, but I expect I won''t have to - I just change the views a lot (XHTML Basic only, reduced amounts of info & links displayed, no images, headers, etc.) Right now, this is what I''m doing: class ListItemsController < ApplicationController before_filter :redirect_wap before_filter :login_required def redirect_wap if @request.host[0,3] == ''wap'' unless self.is_a? WapListItemsController redirect_to :controller => ''wap_list_items'' end end end .... For some reason, I cannot get @request.subdomains to return me anything even though its clearly just splitting host and I can read that fine. But nevermind that bit for now. The only part I really don''t like here is that I''m doing a redirect, which results in an extra roundtrip on an extremely bandwidth limited device. What I really need is to transfer to the other controller on the server-side. Is this at least possible?
Jeremy Huffman wrote:> Yeah, I agree. I pretty much am convinced that I need different > controllers though. I''m subclassing my controller - this way, I can > reuse my existing action''s code but will automatically render different > views. If I need to override the actions I can, but I expect I won''t > have to - I just change the views a lot (XHTML Basic only, reduced > amounts of info & links displayed, no images, headers, etc.)You could mod_rewrite the subdomain into your URL path, thus making it available to Routes. jeremy
Jeremy Kemper wrote:>Jeremy Huffman wrote: > > >>Yeah, I agree. I pretty much am convinced that I need different >>controllers though. I''m subclassing my controller - this way, I can >>reuse my existing action''s code but will automatically render different >>views. If I need to override the actions I can, but I expect I won''t >>have to - I just change the views a lot (XHTML Basic only, reduced >>amounts of info & links displayed, no images, headers, etc.) >> >> > >You could mod_rewrite the subdomain into your URL path, thus making it >available to Routes. > >Good hack, but not everyone uses apache (I don''t for development right now) and I think we should be able to handle this in rails. I suppose though, this is the point where I can put up a patch or shutup? :) Probably this wouldn''t be that hard. I looked at some of the rails code trying to answer this question myself and it doesn''t look like black magic, just something I''d need to spend a bit of time on. Thanks for the input.