form-for

Bootstrap 3 Datetimepicker with Rails form_for

本秂侑毒 提交于 2019-12-12 17:07:27
问题 I am a new Rails developer and I am having trouble using the bootstrap3 datetimepicker together with my rails form_for to save to a DateTime attribute in my ScheduledAccess Model. The one I am using is from http://eonasdan.github.io/bootstrap-datetimepicker/ Code: .form-group = f.label :start_time datetimepicker1.input-group.date = f.text_field :start_time, class:"form-control", id:"scheduled_access_start_time" span.input-group-addon span.glyphicon.glyphicon-calendar .form-group = f.label

Radio button value in rails form_for not being part of params[:model]

时光怂恿深爱的人放手 提交于 2019-12-12 08:53:55
问题 I have an model (CustInfo), which contains 3 attributes: cust_name, age, gender. In my edit view, I use form_for for form submission: <%= form_for @cust[0] do |cust| %> <label for="cname">Customer name: </label> <%= cust.text_field :cust_name, :size => 20 %> <label for="age">Customer age: </label> <%= cust.text_field :age, :size => 5 %> <label for="gender">Gender </label> <%= radio_button_tag(:gender, "F", :checked => (:gender == 'female')? true:false) %><span style="float:left">F</span> <%=

form for nested resource

泄露秘密 提交于 2019-12-12 08:45:12
问题 I have gone through tons of the form_for nested resource questions and can't get any of the solutions to work for me. I figured its time to ask a personalized question. I have two models, jobs and questions, jobs has_many questions and questions belong_to jobs. I used scaffolding to create the controllers and models then nested the resources in the routes.rb. root :to => "pages#home" resources :jobs do resources :questions end get "pages/home" get "pages/about" get "pages/contact" class Job <

How to only change one attribute in a model using form_for in Rails

帅比萌擦擦* 提交于 2019-12-11 20:46:58
问题 I want to change my User model's profile attribute which is just a string in a form_for. I am running into a problem where my password is getting set to blank when I update my profile attribute. That is, my user account has a password, but when I change my profile, my password becomes blank. The next time I try to log in, I just leave the password field blank. How do I change my profile field without changing my password? Thanks. Here is my form below and update action. I'm passing a hidden

Is it possible to catch ruby on rails error pages and do my own error handling?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:34:36
问题 I get this page when incorrect form login details are entered: When credentials are correct the user is just logged in. When they're invalid this error page comes up. How do I catch this page and handle the error myself? E.G. redirect to same page or add the error to my array of errors rather than have this page show up? Controller: class UserController < ApplicationController def index end def new @user = User.new end def create @user = User.new(params[:user]) if @user.valid? user = Parse:

fields_for doesnt working when form_for use symbol

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:26:41
问题 i have a form_for code <%form_for :a,:url=>{:controller=>"biz/a",:action=>"save"},:html =>{:multipart => true} do |f| %> ..... <%f.fields_for :b do |b|%> ..... <%b.fields_for :apples do |apple|%> ... <%end%> .... <%end%> it outputs the html code without fields_for function <textarea cols="40" id="a_b_apples_content" name="a[b][apples][content]" rows="20" style="width:500px;height:100px;border:1px #889BAA solid;color:#999;font-size:12px;padding:6px;"></textarea> when i change the form_for to :

form_for , undefined method name

强颜欢笑 提交于 2019-12-11 08:12:25
问题 I want to add a comment model to my rails project but i got error in the render page saying: error: Showing /Users/sovanlandy/rails_projects/sample_app/app/views/shared/_comment_form.html.erb where line #4 raised: undefined method `comment_content' for #<Comment:0x007fd0aa5335b8> . Here are the related code comment.rb class Comment < ActiveRecord::Base attr_accessible :comment_content belongs_to :user belongs_to :micropost validates :comment_content, presence: true validates :user_id,

Rails form_tag form writing - with non-active record model

♀尐吖头ヾ 提交于 2019-12-08 16:29:35
问题 I'm somewhat of a Rails newbie. I'm writing a couchrest-rails app, so am not using activerecord for this model. I just figured out that that means that form_for(@model) won't work. I'm trying to work out how to use form_tag -- but most of the examples don't involve new & create actions. This is wrong: <h1>New article</h1> <% form_tag new_article_url(@article), :method => :post do |f| %> <%= f.error_messages %> <p> <%= f.label :title %><br /> <%= f.text_field :title %> </p> <p> <%= f.submit

Select option does not work in Rails using MaterializeCSS

此生再无相见时 提交于 2019-12-08 03:26:27
问题 I have a select option in my form_for in rails. It was working before I installed materialize but after installing it, it doesnt work anymore. Please see my code below: Game model class Game < ActiveRecord::Base GENRES = ['Action', 'Adventure', 'RPG', 'Simulation', 'Strategy', 'Sports', 'Others'] PLATFORMS = ['3DS', 'WII U', 'NX', 'PC', 'Playstation', 'XBOX', 'PS Vita', 'Mobile', 'Others'] end new.html.erb <h1> Add Game </h1> <%= form_for :game, url: games_path do |f| %> Title: <%= f.text

Capitalize f.text_field

时光毁灭记忆、已成空白 提交于 2019-12-07 01:40:44
问题 I have a form_for and I want that any value inside x.textField appear with the first letter in Upcase (I'm talking about the edit where the textfield are prefilled by the db values). 回答1: You can capitalize it like this: <%= form_for ... do |f| %> <%= f.text_field :name, :value => f.object.name.capitalize %> 回答2: You can do this with CSS... = f.text_field :some_attribute, style: 'text-transform: capitalize;' 回答3: Pan Thomakos's solution will work, but if you don't want to have to add :value =