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

How to select foreign_key using friendly_id's hash_id? #617

Open
sscirrus opened this issue Jun 21, 2019 · 0 comments
Open

How to select foreign_key using friendly_id's hash_id? #617

sscirrus opened this issue Jun 21, 2019 · 0 comments

Comments

@sscirrus
Copy link

sscirrus commented Jun 21, 2019

My project has a select box where one can choose each user's project, but user.project_id is set according to be project's hash_id, not its actual id. So, the browser only knows the user and the project's hash_id.

Here's the code I'm using (project is already defined):

<%= best_in_place user, :project_id, as: :select, collection: @projects.collect{|d| [d.id, d.name]}, value: project.hash_id %>

The above code doesn't work - it ignores the value and sets everything to the first option, regardless of what the DB value is. I'd like it so it shows the correct value.

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

1 participant