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

params hash keys #1405

Closed
graudeejs opened this Issue Sep 10, 2013 · 7 comments

Comments

Projects
None yet
4 participants
@graudeejs
Contributor

graudeejs commented Sep 10, 2013

If you submit form, all keys in hash are strings

however if you defined

put :edit, :map => '/:id' do
...
end

then id will be symbol in params hash i.e. params[:id]

I propose to extend params so that no matter string or symbol key is request it returns expected value, or at least convert them to string or symbols.

@graudeejs

This comment has been minimized.

Show comment
Hide comment
@graudeejs

graudeejs Sep 10, 2013

Contributor

Example:

{
  "_method"=>"put",
  "authenticity_token"=>  ".....",
  "bookmark"=>
  {
     "title"=>"FreeBSD",
     "url"=>"http://www.freebsd.org/"
  },
 :id=>"6"
}
Contributor

graudeejs commented Sep 10, 2013

Example:

{
  "_method"=>"put",
  "authenticity_token"=>  ".....",
  "bookmark"=>
  {
     "title"=>"FreeBSD",
     "url"=>"http://www.freebsd.org/"
  },
 :id=>"6"
}
@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Sep 18, 2013

Member

Makes sense.
And string key is not cool.
I want to propose to separate params to two variables.
How about this?

get :foo, :map => "/:id" do
  "id : #{captures[:id]}, query : #{params[:foo]}"
end

# get "/1?foo=bar"
# body #=> "id : 1, query : bar"

This big change will cut the compatibility.

Member

namusyaka commented Sep 18, 2013

Makes sense.
And string key is not cool.
I want to propose to separate params to two variables.
How about this?

get :foo, :map => "/:id" do
  "id : #{captures[:id]}, query : #{params[:foo]}"
end

# get "/1?foo=bar"
# body #=> "id : 1, query : bar"

This big change will cut the compatibility.

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Sep 18, 2013

Member

So, params would only have real post/get query variables? Seems really unorthodox.

Member

ujifgc commented Sep 18, 2013

So, params would only have real post/get query variables? Seems really unorthodox.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Sep 18, 2013

Member

Sure, I think this way is not best. But I have no idea...

Member

namusyaka commented Sep 18, 2013

Sure, I think this way is not best. But I have no idea...

@Ortuna

This comment has been minimized.

Show comment
Hide comment
@Ortuna

Ortuna Sep 22, 2013

Member

Maybe I'm missing something but I think we're looking for HashWithIndifferentAccess

Member

Ortuna commented Sep 22, 2013

Maybe I'm missing something but I think we're looking for HashWithIndifferentAccess

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Sep 22, 2013

Member

Yeah... A recursive one.

Member

ujifgc commented Sep 22, 2013

Yeah... A recursive one.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Oct 18, 2013

Member

Should we use HashWithIndifferentAccess for params?

Member

namusyaka commented Oct 18, 2013

Should we use HashWithIndifferentAccess for params?

Ortuna added a commit that referenced this issue Oct 18, 2013

Ortuna added a commit that referenced this issue Oct 18, 2013

issue #1405 - params hash keys
- the `params` variable is converted into a HashWithIndifferentAccess
  object
- fixes #1405

@Ortuna Ortuna closed this in #1470 Oct 23, 2013

Ortuna added a commit that referenced this issue Oct 23, 2013

namusyaka added a commit to namusyaka/padrino-framework that referenced this issue Oct 27, 2013

issue #1405 - params hash keys
- the `params` variable is converted into a HashWithIndifferentAccess
  object
- fixes #1405

Conflicts:

	padrino-core/lib/padrino-core/application/routing.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment