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

Only passing string values #108

Open
richarddwalsh opened this issue Jan 24, 2014 · 2 comments
Open

Only passing string values #108

richarddwalsh opened this issue Jan 24, 2014 · 2 comments

Comments

@richarddwalsh
Copy link

How can I define that the object is a pointer rather than a string.

No matter what I do, I get the following

111 invalid type for key menu, expected *Menu, but got string

@Rockstage
Copy link

I'm struggling for days with the same thing.
I want to be able to pass Numbers and Dates to parse but it only sends Strings.

I managed to save a number field by adding @user.gender = params[:gender].to_i but no matter what number I send from the form, the parse database receives a 0.....

Please help.

@terrybu
Copy link

terrybu commented Nov 29, 2014

If you are talking about Rails, it might be a strong params issue.

@post.postid = post_params[:postid].to_i

That should work as long as you have the strong params options set correctly in the bottom of your controller. I think it becomes 0 because it's quietly failing.

It shouldn't look like this.
def post_params
params[:post]
end

It should look like this.
def post_params
params.require(:post).permit(:post_boolean, :title, :postid)
end

http://stackoverflow.com/questions/27199901/how-to-pass-integer-or-boolean-value-to-params-and-json-through-rails-form/27204612#27204612

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

3 participants