-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rails 4.2 text_field issue #620
Comments
Yes, this is by design for security reasons. |
It would be nice, yes. Right now I am also forced to do: <%= f.label tag.to_s.titleize %>
<% tag_sym = "#{tag.to_s.singularize}_list".to_sym %>
<% tag_list = "#{tag.to_s.singularize}_list" %>
<%= f.text_field tag_sym, value: @article.send(tag_list).to_s, :placeholder => "Comma-separated list of #{tag.to_s}", class: 'form-control' %> Note: I asked this on StackOverflow as well 😦 |
The best option might be to make a custom input for the form builder |
Seems like the easiest way is to make a custom tag_list_field where the input type defaults to text or can be specified. Thanks for the help! |
… separated by default. See: mbleigh/acts-as-taggable-on#620
Maybe just add |
What kind of security feature are you talking about? |
Why was this closed when no explanation for this change was provided? |
This should be noted in a changelog somewhere because on upgrade to 4.2 I had some production projects lose tag data because when the resources were saved again the commas were lost and it created new tags. |
Created a wiki-page, addressing this issue. |
For
|
When using `tag_list` in rendering a `text_field`, you now need to `to_s` the value manually. References: mbleigh/acts-as-taggable-on#620 https://github.com/mbleigh/acts-as-taggable-on/wiki/Add-a-tag-field-to-forms-in-Rails--4.2-and-above Fixes #104
Issue caused by known changes in rails 4.2. As suggested by https://stackoverflow.com/questions/28776612/rails-acts-as-taggable-on-removes-commas-when-editing and mbleigh/acts-as-taggable-on#620
This was our solution: module ActionView::Helpers::TagHelper
private
def tag_option_with_tag_list_support(key, value, escape)
if value.is_a?(ActsAsTaggableOn::TagList)
value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s
end
tag_option_without_tag_list_support key, value, escape
end
alias_method_chain :tag_option, :tag_list_support
end |
Hi. I'm using ruby 2.1.5 and recently upgraded to rails 4.2. I noticed ActionView::Helpers::Tags::TextField no longer calls html_safe on its value, which means that for a post with tag_list ['ruby', 'rails'], the following erb block
<%= f.text_field :tag_list %>
produces
<input type="text" value="ruby rails" name="post[tag_list]" id="post_tag_list">
rather than
<input type="text" value="ruby, rails" name="post[tag_list]" id="post_tag_list">
It's easily fixed by
<%= f.text_field :tag_list, value: @post.tag_list.to_s %>
but I was wondering if there's a way to go about this issue without having to specify the value option each time?
The text was updated successfully, but these errors were encountered: