simple-form

Rails Routing to New associated model

霸气de小男生 提交于 2020-01-16 18:42:06
问题 I have an App that has Households that visit my agency and I am logging each time a household visits. I select the household in the households index and open the visit view which is in the visits model in my index to select a household and create a new visit I have teh following code on my index view for households: = link_to 'Visit', new_household_visit_path(household), class: 'btn btn-mini' Rake Routes Shows: new_household_visit GET /households/:household_id/visits/new(.:format) visits#new

Rails Routing to New associated model

人走茶凉 提交于 2020-01-16 18:41:30
问题 I have an App that has Households that visit my agency and I am logging each time a household visits. I select the household in the households index and open the visit view which is in the visits model in my index to select a household and create a new visit I have teh following code on my index view for households: = link_to 'Visit', new_household_visit_path(household), class: 'btn btn-mini' Rake Routes Shows: new_household_visit GET /households/:household_id/visits/new(.:format) visits#new

simple_form undefined method `model_name' for NilClass:Class

最后都变了- 提交于 2020-01-16 02:28:10
问题 I'm learning Rails, and I would like to use simple_form. I'm creating a simple app (my first one), and I want to create a signup form. I used rails g scaffold User username:string password:string to create my model and controller. I'm using Foundation gem too, if that's matter, and I install simple_form with the right command for Foundation. I've been looking for answers for two hours, I tried many things, I have no idea of what's wrong with my code. ## app/views/home/index.html.erb ## <%=

undefined method `valid_options' for nil:NilClass with simple_form and Mongoid

自古美人都是妖i 提交于 2020-01-15 05:40:27
问题 I have two models, Category and Post. Category.rb class Category include Mongoid::Document field :title, :type => String has_many :posts, :autosave => true, dependent: :destroy end Post.rb class Post include Mongoid::Document field :title, :type => String belongs_to :category end I'm using simple_form gem If I write in my post form the next: <%= simple_form_for(@post) do |f| %> <%= f.collection_select :category, Category.all, :id, :title, :prompt => "Choose a Category"%> <%= f.input :title %>

Rails 5 - Acts as Taggable On gem - simple form collection select for defined tag lists

扶醉桌前 提交于 2020-01-15 03:54:07
问题 I am trying to learn how to use the Acts as Taggable On gem with Rails 5. I use simple form for forms. I think part of the problem arises out of there not being an association on the models between proposal and randd_fields. I have models called Proposal and Randd::Field. I am trying to tag proposals with tags which are the :title attribute of the Randd::Field table. My models have: Proposal class Proposal < ApplicationRecord acts_as_taggable_on :randd_maturities, :randd_fields, :randd

Creating multiple nested forms using simple_form and rails 4

我的梦境 提交于 2020-01-13 07:44:06
问题 I'm trying to create a simple app with the following models: categories --[has_many]--> questions --[has_many]--> answers I have the following code for creating categories + questions(categories/_form.haml.html): = simple_form_for(@category) do |f| = f.error_notification = f.input :title, label: "Category title: " = f.simple_fields_for :questions, @category.questions.build do |q| = q.input :content, label: "Question content: " = f.button :submit And I'm using all the same code for creating

No errors and no output for rails cocoon gem

痞子三分冷 提交于 2020-01-11 10:31:08
问题 I am working on a dynamically nested form using the cocoon gem. I have two models class CrossTable < ActiveRecord::Base attr_accessible :title, :table_name, :database, :folder_label_id, :foreign_fields_attributes belongs_to :folder_label has_many :foreign_fields accepts_nested_attributes_for :foreign_fields validates :title, :table_name, :database, :folder_label_id, presence: true end class ForeignField < ActiveRecord::Base attr_accessible :cross_table_id, :column_name, :description belongs

Limit simple_form_for associated records number in Ruby on Rails

牧云@^-^@ 提交于 2020-01-07 03:39:08
问题 I have a large psychological test of 251 question. Each user can complete that test many times. So I created Summary model to represent each completion. Each Summary has many Answers. For each Summary I created a form that represents collection of answers, using Slim templater and simple_form gem: = simple_form_for(@summary) do |f| = f.simple_fields_for :answers do |a| .question = a.input :question_id, as: :hidden div= a.object.question.title - if a.object.question.kind_of?

Rails: Attribute required for collection in simple_form

别来无恙 提交于 2020-01-07 03:04:34
问题 We are trying to set required in simple_form. The following setup does not work. <%= f.input :payee_id, :label => t('Payee'), required: true, :collection => BankAccountx.payee_class.where(active: true).map {|x| [x.name, x.id]}, :selected => params[:payee_id], include_blank: true %> Also tried :input_html => {required: true} and it did not work as well. What's the right way to set required in simple_form? 回答1: Found it. If you use this command: rails generate simple_form:install It will create

Rails - undefined method `model_name' for

偶尔善良 提交于 2020-01-06 13:29:32
问题 In the edit function, I am fetching the object that will be edited. Unfortunately I have been getting this weird error that I can' understand its cause so far. NoMethodError in Tasks#edit undefined method model_name' for #Hash:0x007fe92d2afeb8 at line#1 in _form.html.erb tasks_controller: def edit uri = URI.parse("http://localhost/tasks/public/api/tasks/"+params[:id]) response = Net::HTTP.get_response(uri) @task = JSON.parse(response.body)['task'] end _form.html.erb <%= simple_form_for(@task)