I am new to Rails and I ran into a problem. I have
Models
Model1
id: integer
account_id: integer
Account
id: integer
I have a check in Model1 as follows:
Model Code:
validates :account_id, :inclusion => { :in => Account.find(:all).collect(&:id)}
I use the drop-down menu for View code:
<%= f.select :account_id, @accounts.collect {|acc| [acc.name, acc.id]}, {:prompt => 'Select Account' }, { :selected => @defaultaccount, :class => 'selectwidth' } %>
I use client-side validation to validate the fields before submitting the form. I use Heroku to deploy my application.
, , 1. , . , , "", validates_inclusion_of, . , , , .
validates_inclusion_of rails 3 validates: account_id,: include = > {: in = > {}} . model1. .
, 1 , .
, ? ? , , , , .
, , , , , . ? , .
Config,
3
Asset
:
Kaminari