formtastic

ActiveAdmin has_many form not saved if parent model is new and is NOT NULL in child model

十年热恋 提交于 2021-02-07 18:32:36
问题 I have two models, Room and Student . Room has_many Student s. Student belongs_to Room . I got an error Room can't be blank when I try to add Student to Room during creating a new Room. My guess is that, upon submission, child object (student) is saved before parent object (room) is saved. Is there a way to bypass the order without remove the NOT NULL setting on room_id? Or my guess is wrong? Or even worse, I am doing it wrong? # app/models/room.rb class Room < ActiveRecord::Base validates

Client_side_validations gem with formtastic in jquery modal view not working

守給你的承諾、 提交于 2020-06-18 11:01:57
问题 I'm trying to get the client_side_validations gem to validate my form in a jquery modal view, but the validations aren't occurring (at least insofar as the errors aren't appearing inline). I'm using the formtastic gem as well, so I've installed client_side_validations and client_side_validations-formtastic gems for formtastic support. Note: I include the rails.validations javascript in my app/views/layouts/application.html.erb Here is my code: app/views/home/index.html.erb: <script type="text

Client_side_validations gem with formtastic in jquery modal view not working

浪尽此生 提交于 2020-06-18 11:00:04
问题 I'm trying to get the client_side_validations gem to validate my form in a jquery modal view, but the validations aren't occurring (at least insofar as the errors aren't appearing inline). I'm using the formtastic gem as well, so I've installed client_side_validations and client_side_validations-formtastic gems for formtastic support. Note: I include the rails.validations javascript in my app/views/layouts/application.html.erb Here is my code: app/views/home/index.html.erb: <script type="text

ActiveAdmin Form not saving nested object

╄→尐↘猪︶ㄣ 提交于 2020-01-14 12:38:19
问题 Using ActiveAdmin with Rails 4, I have two models, Document and Attachment with a one-to-many relationship between them. # models/document.rb class Document < ActiveRecord::Base has_many :attachments accepts_nested_attributes_for :attachments end # models/attachment.rb class Attachment < ActiveRecord::Base belongs_to :document end I registered the models and included permit_params for all the fields in each. Now I used has_many in the form view in the below code. This shows an option to add

ActiveAdmin Form not saving nested object

[亡魂溺海] 提交于 2020-01-14 12:37:08
问题 Using ActiveAdmin with Rails 4, I have two models, Document and Attachment with a one-to-many relationship between them. # models/document.rb class Document < ActiveRecord::Base has_many :attachments accepts_nested_attributes_for :attachments end # models/attachment.rb class Attachment < ActiveRecord::Base belongs_to :document end I registered the models and included permit_params for all the fields in each. Now I used has_many in the form view in the below code. This shows an option to add

Is there any way to create a form with formtastic without a model?

孤街浪徒 提交于 2020-01-12 01:41:34
问题 I would like to use formtastic to create form but I don't have a model associated with that (login form with username, password and openid URL). Of course I could create a model to do that but that model was just a hack without any useful code in it. 回答1: You can pass a string instead of a model, which will be used to generate the field names: <% semantic_form_for 'user', :url => 'login' do |f| %> <% f.inputs :name => 'Login Details' do %> <%= f.input :username %> <%= f.input :password %> <%

How to pre-check checkboxes in formtastic

人盡茶涼 提交于 2019-12-31 14:33:53
问题 I have a form I'm trying to set up ... Users can have many posts, and each post can have many people watching it. The Watch model is set up polymorphically as 'watchable' so it can apply to different types of models. It has a user_id, watchable_id, watchable_type and timestamps as attributes/fields. This is soley so that when people comment on a post, users watching the post can get an email about it. What I'm trying to do is show the user a list of users that they can tag on each post, which

Formtastic::UnknownInputError in ActiveAdmin::Devise::Sessions#new

偶尔善良 提交于 2019-12-24 17:28:04
问题 Using Rails 5.0.0.beta1. Installed Active Admin and Devise. Here is Gemfile contents: # Backend gem 'activeadmin', '~> 1.0.0.pre2' # Authentication # Master branch is added for Rails 5 support # https://github.com/plataformatec/devise/pull/3714 gem "devise", :github => 'plataformatec/devise', :branch => 'master' Followed instruction installation here. rails g active_admin:install User rake db:migrate rake db:seed rails server When I'm trying to enter /admin , the following error appears:

Add custom button to active admin form

孤街醉人 提交于 2019-12-24 14:08:18
问题 Is it at all possible to add a custom button along side the submit and cancel button that is generated with f.actions in this case The documents state form do |f| f.semantic_errors # shows errors on :base f.inputs # builds an input field for every attribute f.actions # adds the 'Submit' and 'Cancel' buttons link_to 'Preview', preview_my_admin_panel_posts_path(@post) end How could I add something here? Update So i have got my custom button to show now with this inputs 'Submit' do f.actions do

belongs_to association and formtastic

£可爱£侵袭症+ 提交于 2019-12-24 11:53:25
问题 I have a model Product which has a belongs_to association with another model Type. In the product's form, I'm using formtastic to display a select tag with all the types available in the database, like this: <%= f.input :type %> The select is showing up OK, but each option of it is an object instance of the Type model as a string, for example: #<Type:0x00eff180c85c8> Instead of that, I'd like to display the 'title' attribute of it, like: Electronic Domestic ... Any ideas? 回答1: Try the member