rest - URL encoded route to Rails controller -
I have URL encoded resources such as:
This is for A harsh webservice problem that uses user login in path is that the controller in the rail does not decode% 20 I get the following error:
ActionController :: routing error ({: No route matched with method = & gt;: post} "/Joe%20Bloggs/index.xml"):
What exactly am I trying to do 2 options Get one of (As my registration handler using authlogic):
-
Either (preferably) users to register the user name with the spaces in them, and these are my controllers Has been properly received for. Authlogic default spaces & amp; @ /. Characters - which are ok with me if I can work it ...
-
Or I can restrict authlogic so that the free space can be destroyed. I know that I can do this with:
.merge_validates_format_of_login_field_options ...
But I have given the correct syntax to provide a new sentence Not fully convinced Regex and the message to return to failure ...
Any suggestions greatly appreciated!
Usually this is better for better situations like your URL-safe "slug" field For example:
class user & lt; ActiveRecord :: Before the base_validation: assign_slug def to_param # methods can not be used on alias_method pre-defined methods, #DBB connects # ActiveRecord accessors after self.slug end-def unique_slog? If you return (self. Slug.blank?) If (new_record?) Comes back to himself. Class. Coat (: Terms => ['slug =?', Self.slug]) == 0 Others themselves category. (Slug =? And id! =? ', Self.slug, self.id]) == 0 Specify end-of-the-end def_sulf return if (slug.present?) Base_slug = self.name.gsub / \ S + /,' - '). Hunt for a unique slug starting with gsub (/ [^ \ w \ -] /, '') self.slug = base_slug count = 1 # slug1. While slugNNN (! Unique_slug?) Self.slug = base_slug + Count.to_s count + = 1 end end end
This can solve the problem of being a non-url-friend's name. Mercury is particularly beautiful when it comes to the production of to-palm dots.
Comments
Post a Comment