Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError if I try to create a subdomain(slug) with starting with capital letter #286

Closed
mazharoddin opened this issue Jan 11, 2016 · 11 comments

Comments

@mazharoddin
Copy link
Contributor

Hi,
I am getting NoMethodError if I try to create a subdomain(slug) with capital letter, I created Mac subdomain, it got successfully created, but if I try to access using mac.xxx.com, I am getting NoMethodError, but it works without any issue if I give mac as subdomain.

undefined method `host' for nil:NilClass
    def url_options
      @_url_options ||= {
        :host => request.host,
        :port => request.optional_port,
        :protocol => request.protocol,
        :_recall => request.path_parameters

actionpack (4.2.5) lib/action_controller/metal/url_for.rb:27:in `url_options'
actionview (4.2.5) lib/action_view/routing_url_for.rb:121:in `url_options'
actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:274:in `call'
actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:347:in `block (2 levels) in define_url_helper'
@mazharoddin
Copy link
Contributor Author

Hi,
Apart from above issue, I am able to create site with same slug but one with lower case and another uppercase.

@owen2345
Copy link
Owner

fixed!
you can not create sites with uppercase or capital letters in domain.

@mazharoddin
Copy link
Contributor Author

Thanks,
Please let me know if fix already checked in, I pulled latest code to test, but still I am able to create subdomain with capital letter, so still problem persists.

Parameters: {"utf8"=>"✓", "authenticity_token"=>"V4/d78ObWwKx7nJzMTRTfdKujFgra8ovAENVx2uwwew78NzZHHGl6H2MKwyCb3qvm/kH+Yu+4IQkqqchSjKbgA==", "site"=>{"slug"=>"Mac", "name"=>"Mac", "description"=>""}}


@mazharoddin
Copy link
Contributor Author

Hi,
I gone through your commits, looks like you added fix for creating sudomain with capital letter issue, but now I am facing Nil class error even if I try to create subdomain with lower case, also it would be good to lowercase the subdomain name while saving instead of restricting users to create the subdomain with Capital letter. Here is the sample code from my earlier project for reference. Thanks.

class Account < ActiveRecord::Base

 before_validation :downcase_subdomain
---
---
Private
 def downcase_subdomain
      self.subdomain = subdomain.try(:downcase)
    end

@owen2345
Copy link
Owner

@mazharoddin
Copy link
Contributor Author

Yes, I was just showing my code as reference, so in our case we need to downcase the slug.

@owen2345
Copy link
Owner

I think the parameterize method is already changing into lowercase, but anyway I added the downcase method.
parameterize: http://apidock.com/rails/String/parameterize
Regards,

@mazharoddin
Copy link
Contributor Author

Ok, let me try latest changes. Thanks.

@mazharoddin
Copy link
Contributor Author

No luck, still I am getting same error as I mentioned in #289 issue. Below error I got when I tried to create subdomain using "admin/settings/sites" menu.

undefined method `get_languages' for nil:NilClass
        options.delete(:locale)
      else
        options[:locale] = I18n.locale if !options[:locale].present? && current_site.get_languages.size > 1
      end
      options[:locale] = nil if options[:locale].present? && current_site.get_languages.first.to_s == options[:locale].to_s
    end

Application Trace | Framework Trace | Full Trace

/Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-aa93e180faf6/app/helpers/camaleon_cms/frontend/application_helper.rb:33:in `cama_url_to_fixed'
draper (1.4.0) lib/draper/helper_proxy.rb:29:in `block in define_proxy'
/Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-aa93e180faf6/app/decorators/camaleon_cms/site_decorator.rb:162:in `the_url'
/Users/mazharoddin/.rvm/gems/ruby-2.2.2@rails4.2.5/bundler/gems/camaleon-cms-aa93e180faf6/app/helpers/camaleon_cms/site_helper.rb:30:in `cama_site_check_existence'

@owen2345
Copy link
Owner

Fixed!
previous fix was using parameterize method where domain was converting into my-domain-com and not my-domain.com
to solve the current installations with this problem, please go to your database and update the slug in term_taxonomy table.
See screenshot:
2016-01-13_0704

@mazharoddin
Copy link
Contributor Author

Thanks, its fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants