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

Rhom newORM does not remove {} from object IDs #553

Open
jtara opened this issue Mar 23, 2015 · 2 comments
Open

Rhom newORM does not remove {} from object IDs #553

jtara opened this issue Mar 23, 2015 · 2 comments
Assignees

Comments

@jtara
Copy link

jtara commented Mar 23, 2015

It seems that at some point in Rhodes' evolution, Rhom started ignoring {} around object IDs. I'm not quite sure when that started, but it is easily demonstrated. Search for the same object ID, with or without {} around it. With new_orm = 0 both will succeed. With new_orm = 1 it will fail with the surrounding {}.

I'm not sure what the developers' intention is. Ignoring {} seems a hack to work-around the fact that Rhodes url_for() likes to gratuitously add {} around object IDs in URLs. There is no good reason that I know of to do this! Maybe the thought was that this would make it easy to use JSON parsing to turn the object ID into a native type?

In any case, the {} are a pain to deal with. I have old code sprinkled everywhere that looks like this:

 @venue = Venue.find @params['id'].to_s.gsub /[{}]/, '' 

However, this seems no longer needed, because at some point somebody changed Rhom to just ignore the {}.

This hasn't been applied to newORM, though, and so it is inconsistent with oldORM.

You should decide what to do about the whole {} mess, and then whether or not this should still be "fixed" in Rhom.

@jtara
Copy link
Author

jtara commented Mar 23, 2015

I notice that newORM IDs do not have a decimal point (or period) in them, as oldORM IDs do.

This seems a red herring, though. I can't think of a reason that this would influence a decision to include or not include {} around object IDs in URLs.

There's no REST "standard" that I know of that uses {}. I have no idea where this convention came from, and perhaps the URL convention should be reviewed. It would at least be informative to understand why the {} are even being used.

@jtara
Copy link
Author

jtara commented Mar 26, 2015

As I workaround, I added this helper tobrowser_helper.rb:

  # Removes the *&^! {} from around the ID parameter
  private
  PARAM_ID_REGEX = Regexp.new /[{}]/
  public
  def param_id
    @params['id'].to_s.gsub PARAM_ID_REGEX, ''
  end

@alex-epifanoff alex-epifanoff self-assigned this Nov 7, 2017
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