form-helpers

Add attribute to rails helper text field?

北城余情 提交于 2019-12-01 03:19:30
I have a rails helper text field from devise that uses html and atomatically validates the type="email" field. I want to add the attribute novalidate='novalidate' to it, but i do not know how.. Heres the code.. any suggestions? <%= form_for(resource, :as => resource_name, :url => session_path(resource_name) ) do |f| %> <p><%= f.label :login %><br /> <%= f.email_field :login %></p> Just do: <%= f.email_field :login, :novalidate => 'novalidate' %> UPDATE -- If you want to add an attribute to the FORM tag, the syntax is slightly different: <%= form_for(resource, :as => resource_name, :url =>

In rails, whether to use form helpers or not to?

≯℡__Kan透↙ 提交于 2019-11-30 20:28:27
In rails, is it recommended to use form helpers? Internally, everything boils down to plain html then why not write the html directly? Performance will obviously be better in writing direct html than using helpers. Is using form helpers like a convention or something that rails developers must follow? Define performance. Your performance or the applications? Say you have the same rhtml snippet spread out across your views. Say you have it in thousands of places. Maybe you even haven't gotten it exactly the same in all places. Now your customer wants to change this (maybe different order of

collection_select method gives error in Rails 3.1.1

南笙酒味 提交于 2019-11-30 08:21:59
问题 I have a Model called Category and other Model Product. They have has_many and belongs_to relation. But code in my view <p><%= f.collection_select(:product, :category_id, Category.all, :id, :name)%> is giving me undefined method `merge' for :name:Symbol Any clue what is wrong with it? 回答1: Chances are you have something like this: <%= form_for @product do |f| %> Because f is already tied to product , you don't need to include it as your first argument, so it should just be: <%= f.collection

collection_select method gives error in Rails 3.1.1

给你一囗甜甜゛ 提交于 2019-11-29 06:35:14
I have a Model called Category and other Model Product. They have has_many and belongs_to relation. But code in my view <p><%= f.collection_select(:product, :category_id, Category.all, :id, :name)%> is giving me undefined method `merge' for :name:Symbol Any clue what is wrong with it? Chances are you have something like this: <%= form_for @product do |f| %> Because f is already tied to product , you don't need to include it as your first argument, so it should just be: <%= f.collection_select :category_id, Category.all, :id, :name %> Or, you could not use f. : <%= collection_select :product,

link_to delete url is not working

本小妞迷上赌 提交于 2019-11-27 22:00:24
I have the following link_to delete url in my app <%=link_to "Delete",blog_path(@blog.id), :method => :delete, :class => "delete", :confirm => "Are you sure ?"%> It does not seem to be working.When I click this url, it just takes me to the show path.Can someone please tell me how to fix this. Thanks. Sean Ahrens Are you using jQuery? If so, I think the problem could be that you are using jQuery without the updated rails.js file. Download rails.js here: https://github.com/rails/jquery-ujs/raw/master/src/rails.js Drop it in your javascripts directory, overwriting the rails.js that comes default

rails erb form helper options_for_select :selected

自作多情 提交于 2019-11-27 13:34:07
问题 I have an edit form in erb. <%= form_for @animal do |f| %> Within the code I have a select with options: <%= f.select :gender, options_for_select([['Mare'], ['Stallion'], ['Gelding']], :selected => :gender) %> However, the select is not showing the correct selected value . What could I be doing wrong? I can get it to work if I hardcode it but of course that is not a viable option. 回答1: In your code, your options_for_select() call sets the selected value to "gender" and does not attempt to use

link_to delete url is not working

狂风中的少年 提交于 2019-11-27 04:33:08
问题 I have the following link_to delete url in my app <%=link_to "Delete",blog_path(@blog.id), :method => :delete, :class => "delete", :confirm => "Are you sure ?"%> It does not seem to be working.When I click this url, it just takes me to the show path.Can someone please tell me how to fix this. Thanks. 回答1: Are you using jQuery? If so, I think the problem could be that you are using jQuery without the updated rails.js file. Download rails.js here: https://github.com/rails/jquery-ujs/raw/master

How to use Simple Ajax Beginform in Asp.net MVC 4? [closed]

末鹿安然 提交于 2019-11-26 14:21:27
I am new in Asp.net MVC and i researched about Ajax.BeginForm but when i apply codes it did not work. Can you share very simple example with Ajax.Beginform with View, Controller, Model? Thanks. Alamakanambra Simple example: Form with textbox and Search button. If you write "name" into the textbox and submit form, it will brings you patients with "name" in table. View: @using (Ajax.BeginForm("GetPatients", "Patient", new AjaxOptions {//GetPatients is name of method in PatientController InsertionMode = InsertionMode.Replace, //target element(#patientList) will be replaced UpdateTargetId =

How to use Simple Ajax Beginform in Asp.net MVC 4? [closed]

ぐ巨炮叔叔 提交于 2019-11-26 03:09:22
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I am new in Asp.net MVC and i researched about Ajax.BeginForm but when i apply codes it did not work. Can you share very simple example with Ajax.Beginform with View, Controller, Model? Thanks. 回答1: Simple example: Form with textbox and Search button. If you write "name" into the