def create
@school = current_user.build_school(school_params)
causes the above error my models are users has_one profile, profile
has_many schools, profile belongs_to user, school belongs_to profile
def create
@school = current_user.build_school(school_params)
causes the above error my models are users has_one profile, profile
has_many schools, profile belongs_to user, school belongs_to profile
Why not kindly pointing out the error and offer a suggestion to assist
the OP instead?
Yes. I’m top posting.
On 2 January 2016 at 20:51, fugee ohu [email protected] wrote:
def create
@school = current_user.build_school(school_params)causes the above error my models are users has_one profile, profile has_many
schools, profile belongs_to user, school belongs_to profile
What makes you think that current_user.build_school is valid code?
Colin
what should the create action be? i tried
@school = current_user.build_school(school_params)
On 2 January 2016 at 22:21, [email protected] wrote:
Why not kindly pointing out the error and offer a suggestion to assist the OP
instead?
Because one learns more by working out the error for oneself. If the
OP goes and looks at the documentation that he thought said that he
should be able to do this then he will see the error. If he cannot
work it out then I assume he will ask again.
Yes. I’m top posting.
Should I just point out the way to fix that or should I point you to
documentation that will help you to fix it for yourself?
Colin
what should the create action be
@school = current_user.create_school(school_params)
Sorry Colin I fell asleep Here’s how I worked it out
<%= form_for(@school) do |school_form| %>
<% school_form.fields_for :profiles do |f| %>
On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
“Ruby on Rails: Talk” group.
has_one :profile, dependent: :destroy
has_many :schools, through: :profile, dependent: :destroy
On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
“Ruby on Rails: Talk” group.
@school = current_user.create_school(school_params)
undefined method `create_school’ for #User:0xb4c85050
@school = current_user.create_school(school_params)
undefined method `create_school’ for #User:0xb4e407a0
On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
“Ruby on Rails: Talk” group.
i see, but that results in Mysql2::Error: Duplicate entry ‘0’ for key
‘PRIMARY’: INSERT INTO schools
VALUES ()
that’s a reference to the new action, i’m asking about the create action
where create_association is used, not build_association
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs