simple-form-for

Empty array value being input with simple_form entries

非 Y 不嫁゛ 提交于 2020-01-05 04:20:18
问题 I'm still new to rails and simple_form and have been trying to implement a multiple select option to give a user multiple roles. Current input looks like this <%= f.input :secondary_role, :collection => UseridRole::VALUES, :include_blank => false,:label => "Secondary Role(s):", :input_html => { :class => " simple_form_bgcolour simple_form_position overide_selection_field_width", :size => 4, multiple: true } %> So, this does work, but is including an empty value at the start of my array:

When I click submit button in my form, create action is supposed to work but it is rather processed by new action

感情迁移 提交于 2019-12-13 06:51:06
问题 In my application, I have a form that is supposed to be processed by create action but it is rather processed by new action. This problem is happening in my post task form, but in my other form (registration form), it is working very well (it is processed by create action). So I thought maybe the culprit is in my model relationships so I will post it here as well: User model has_many :client_relationships, class_name: "Task", foreign_key: "client_id", dependent: :destroy has_many :worker

No Route Matches: Missing required [:id] when using nested namespace

别说谁变了你拦得住时间么 提交于 2019-12-12 01:56:11
问题 this is my routes.rb filled with Rails.application.routes.draw do namespace :main, path: ':master_url' do root 'sites#index' namespace :dashboard do root 'dashboards#index' #get 'masters/index' resources :masters end get "/:action" => 'sites#:action' end root 'main/sites#index' end this is command rake routes main_root GET /:master_url(.:format) main/sites#index main_dashboard_root GET /:master_url/dashboard(.:format) main/dashboard/dashboards#index main_dashboard_masters GET /:master_url

Rails 4 _form partial creates new record but won't edit current record

北战南征 提交于 2019-12-11 20:00:46
问题 I've built a simple app that has businesses, and those businesses have many reviews. I'm using a partial _form to create/update reviews. The create action works fine, but the update action creates a new review instead of updating the review like its supposed to. Here's the relevant code (irrelevant code removed for brevity): Code from routes.rb : resources :businesses do resources :reviews end Code from models/business.rb : class Business < ActiveRecord::Base has_many :reviews, dependent:

Module route in Rails with form_for(@object)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:58:41
问题 I have namespaced Controller Entities::Customers class Entities::CustomersController < ApplicationController ... end and namespaced ActiveRecord model: class Entities::Customer < Entities::User end in my routes.rb file i have: resources :customers, module: :entities The module :entities is there because i don't want to have routes such as: /entities/customers but only: /customers . The problem starts when i'm rendering my form: <%= simple_form_for(@customer) do |f| %> <%= f.input :email %> <%

How can I set timezone in simple form datetime field?

亡梦爱人 提交于 2019-12-10 14:58:52
问题 I have a model with a datetime field, and is stored in UTC, how can I display that date in simple form gem in a specific timezone? Already tried with the option input_html: {value: @model.date.in_time_zone('Eastern Time (US & Canada)')} Note: I can't change the timezone of rails app 回答1: It will work if you set the timezone in the controller: Example: around_action :set_time_zone, if: :current_user private def set_time_zone(&block) Time.use_zone(current_user.time_zone, &block) end 来源: https:/