Rails: v-model VueJS attribute











up vote
0
down vote

favorite












Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:



    # nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"

# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }

# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"

# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"

# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }

#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }


is rails screwing with me?
Can anyone help me?










share|improve this question




















  • 1




    It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
    – DivXZero
    Nov 19 at 20:31










  • You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
    – Carl Markham
    Nov 19 at 20:41












  • to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
    – Rafael Ravena Vicente
    Nov 19 at 20:47















up vote
0
down vote

favorite












Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:



    # nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"

# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }

# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"

# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"

# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }

#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }


is rails screwing with me?
Can anyone help me?










share|improve this question




















  • 1




    It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
    – DivXZero
    Nov 19 at 20:31










  • You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
    – Carl Markham
    Nov 19 at 20:41












  • to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
    – Rafael Ravena Vicente
    Nov 19 at 20:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:



    # nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"

# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }

# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"

# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"

# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }

#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }


is rails screwing with me?
Can anyone help me?










share|improve this question















Inside a form tag i'm placing a hidden_field.
This hidden_field should have a "v-model" attribute.
I've tried all I can think about:



    # nothing shows up
= f.hidden_field :model_attribute, "v-model" => "value"

# that's the one I love the most: it compiles v="{:model=>"value"}"
= f.hidden_field :model_attribute, v: { model: "value" }

# it compiles with the underscore
= f.hidden_field :model_attribute, v_model: "value"

# this throws a compile error, obviously
= f.hidden_field :model_attribute, v-model: "value"

# guess the compiled outcome?
= f.hidden_field :model_attribute, html: { "v-model" => "value" }

#same as previous
= f.hidden_field :model_attribute, options: { "v-model" => "value" }


is rails screwing with me?
Can anyone help me?







ruby-on-rails






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 16:21









7urkm3n

3,38221130




3,38221130










asked Nov 19 at 20:24









Rafael Ravena Vicente

7316




7316








  • 1




    It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
    – DivXZero
    Nov 19 at 20:31










  • You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
    – Carl Markham
    Nov 19 at 20:41












  • to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
    – Rafael Ravena Vicente
    Nov 19 at 20:47














  • 1




    It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
    – DivXZero
    Nov 19 at 20:31










  • You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
    – Carl Markham
    Nov 19 at 20:41












  • to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
    – Rafael Ravena Vicente
    Nov 19 at 20:47








1




1




It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 at 20:31




It looks like the field helpers in rails 5.1+ enforce html5 compatibility, since you are using an invalid field, I don't think you can build the element using the helper, you'd need to write out the entire html tag.
– DivXZero
Nov 19 at 20:31












You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 at 20:41






You should think about why you want that hyphen, and whether or not you need it. I bet you have spent more time than you care to mention on this when you could have just used an underscore. So why not use an underscore?
– Carl Markham
Nov 19 at 20:41














to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 at 20:47




to bind the vuejs to some field, one must use the "v-model" attribute. the underscore option is a fallback for when you are using data attributes, isn't it?
– Rafael Ravena Vicente
Nov 19 at 20:47












1 Answer
1






active

oldest

votes

















up vote
0
down vote













When asking a question. You have to mention, it's VueJS attribute.



Check this LINK



= f.hidden_field :model_attribute, "v-model": "val"





share|improve this answer























  • the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
    – Rafael Ravena Vicente
    Nov 19 at 21:00












  • @RafaelRavenaVicente updated my post check it
    – 7urkm3n
    Nov 19 at 23:54










  • yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
    – Rafael Ravena Vicente
    Nov 21 at 18:30











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382106%2frails-v-model-vuejs-attribute%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













When asking a question. You have to mention, it's VueJS attribute.



Check this LINK



= f.hidden_field :model_attribute, "v-model": "val"





share|improve this answer























  • the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
    – Rafael Ravena Vicente
    Nov 19 at 21:00












  • @RafaelRavenaVicente updated my post check it
    – 7urkm3n
    Nov 19 at 23:54










  • yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
    – Rafael Ravena Vicente
    Nov 21 at 18:30















up vote
0
down vote













When asking a question. You have to mention, it's VueJS attribute.



Check this LINK



= f.hidden_field :model_attribute, "v-model": "val"





share|improve this answer























  • the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
    – Rafael Ravena Vicente
    Nov 19 at 21:00












  • @RafaelRavenaVicente updated my post check it
    – 7urkm3n
    Nov 19 at 23:54










  • yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
    – Rafael Ravena Vicente
    Nov 21 at 18:30













up vote
0
down vote










up vote
0
down vote









When asking a question. You have to mention, it's VueJS attribute.



Check this LINK



= f.hidden_field :model_attribute, "v-model": "val"





share|improve this answer














When asking a question. You have to mention, it's VueJS attribute.



Check this LINK



= f.hidden_field :model_attribute, "v-model": "val"






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 at 14:30

























answered Nov 19 at 20:44









7urkm3n

3,38221130




3,38221130












  • the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
    – Rafael Ravena Vicente
    Nov 19 at 21:00












  • @RafaelRavenaVicente updated my post check it
    – 7urkm3n
    Nov 19 at 23:54










  • yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
    – Rafael Ravena Vicente
    Nov 21 at 18:30


















  • the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
    – Rafael Ravena Vicente
    Nov 19 at 21:00












  • @RafaelRavenaVicente updated my post check it
    – 7urkm3n
    Nov 19 at 23:54










  • yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
    – Rafael Ravena Vicente
    Nov 21 at 18:30
















the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 at 21:00






the expected rendering is <input type="hidden" name="model_class[model_attribute]" id="model_class_model_attribute" v-model="value" value=""/>, no data attributes needed.
– Rafael Ravena Vicente
Nov 19 at 21:00














@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 at 23:54




@RafaelRavenaVicente updated my post check it
– 7urkm3n
Nov 19 at 23:54












yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 at 18:30




yeah, it works great on select, text_field... just had trouble with rendering it on a hidden_field... just posted the question here when I was done trying to do it...
– Rafael Ravena Vicente
Nov 21 at 18:30


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382106%2frails-v-model-vuejs-attribute%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'