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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d4b4fb03-1828-4733-9c0c-fc6b61b4bdc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Colin Law at Jan 2, 2016 at 9:44 pm

    On 2 January 2016 at 20:51, fugee ohu 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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuZmYtmNi_9jWESuqO5ru_sp78uY7FwAtVo-VAg0BbaNg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jelinek at Jan 2, 2016 at 10:21 pm
    Why not kindly pointing out the error and offer a suggestion to assist the OP instead?

    Yes. I'm top posting.
    On Jan 2, 2016, at 3:44 PM, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu 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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuZmYtmNi_9jWESuqO5ru_sp78uY7FwAtVo-VAg0BbaNg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1B5726EC-44E1-4E59-88D2-4536B5BD68BC%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Jan 2, 2016 at 10:39 pm

    On 2 January 2016 at 22:21, 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
    On Jan 2, 2016, at 3:44 PM, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu 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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuZmYtmNi_9jWESuqO5ru_sp78uY7FwAtVo-VAg0BbaNg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1B5726EC-44E1-4E59-88D2-4536B5BD68BC%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvpK_bAGGNnxqW2Mb4E2g56hVfHGaoRVWiwLD8d8Vitiw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jelinek at Jan 2, 2016 at 11:20 pm
    No, you've mentioned top posting and your dislike of it countless times. 🌶
    On Jan 2, 2016, at 4:38 PM, Colin Law wrote:

    On 2 January 2016 at 22:21, 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
    On Jan 2, 2016, at 3:44 PM, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu 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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuZmYtmNi_9jWESuqO5ru_sp78uY7FwAtVo-VAg0BbaNg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1B5726EC-44E1-4E59-88D2-4536B5BD68BC%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvpK_bAGGNnxqW2Mb4E2g56hVfHGaoRVWiwLD8d8Vitiw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8C73A13E-1C57-458F-B7FF-E32E8A07CB12%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 12:17 am
    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 4:45:20 PM UTC-5, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu <fuge...@gmail.com <javascript:>>
    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
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/de5d9fd2-355f-4d62-b24b-1ed86f702f3d%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 12:29 am
    what should the create action be? i tried

         @school = current_user.build_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu <fuge...@gmail.com <javascript:>>
    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
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/eece6790-33af-45fb-b5ad-30d168e12843%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 12:32 am
    what should the create action be

         @school = current_user.create_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:

    On 2 January 2016 at 20:51, fugee ohu <fuge...@gmail.com <javascript:>>
    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
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jelinek at Jan 3, 2016 at 12:38 am
    If a user has many schools you would want

    current_user.schools.new(school_params)

    Unfortunately I don't know how your associations are setup so I'm taking a guess at this. 👍🏻
    On Jan 2, 2016, at 6:32 PM, fugee ohu wrote:

    what should the create action be
    @school = current_user.create_school(school_params)
    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:
    On 2 January 2016 at 20:51, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/06B0E9C6-8994-4217-9C29-F7D1CAE65DCC%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 12:45 am

    On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
    If a user has many schools you would want

    current_user.schools.new(school_params)

    Unfortunately I don't know how your associations are setup so I'm taking a
    guess at this. 👍🏻

    On Jan 2, 2016, at 6:32 PM, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:

    what should the create action be

    @school = current_user.create_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:
    On 2 January 2016 at 20:51, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com
    <https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
       has_one :profile, dependent: :destroy
       has_many :schools, through: :profile, dependent: :destroy


    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1273b9a3-41e1-475f-aff6-68156ec61731%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 1:07 am

    On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
    If a user has many schools you would want

    current_user.schools.new(school_params)

    Unfortunately I don't know how your associations are setup so I'm taking a
    guess at this. 👍🏻

    On Jan 2, 2016, at 6:32 PM, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:

    what should the create action be

    @school = current_user.create_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:
    On 2 January 2016 at 20:51, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com
    <https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
         @school = current_user.create_school(school_params)
    undefined method `create_school' for #<User:0xb4c85050>

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e2d622b4-6717-4a45-8482-d210f9d11c7d%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 1:18 am
    that's a reference to the new action, i'm asking about the create action
    where create_association is used, not build_association
    On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:

    If a user has many schools you would want

    current_user.schools.new(school_params)

    Unfortunately I don't know how your associations are setup so I'm taking a
    guess at this. 👍🏻

    On Jan 2, 2016, at 6:32 PM, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:

    what should the create action be

    @school = current_user.create_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:
    On 2 January 2016 at 20:51, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com
    <https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/efb9eefc-0178-4b5e-94e4-e981bd23d9bf%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 1:40 am

    On Saturday, January 2, 2016 at 7:38:13 PM UTC-5, James Jelinek wrote:
    If a user has many schools you would want

    current_user.schools.new(school_params)

    Unfortunately I don't know how your associations are setup so I'm taking a
    guess at this. 👍🏻

    On Jan 2, 2016, at 6:32 PM, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:

    what should the create action be

    @school = current_user.create_school(school_params)

    On Saturday, January 2, 2016 at 4:45:20 PM UTC-5, Colin Law wrote:
    On 2 January 2016 at 20:51, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com
    <https://groups.google.com/d/msgid/rubyonrails-talk/65959159-b9e1-4e59-90f6-0b1f2dc73ba8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    i see, but that results in Mysql2::Error: Duplicate entry '0' for key
    'PRIMARY': INSERT INTO `schools` VALUES ()

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/771fd966-ab67-42d9-a8ee-5550292e78c8%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Jan 3, 2016 at 1:20 am
    @school = current_user.create_school(school_params)

    undefined method `create_school' for #<User:0xb4e407a0>


    On Saturday, January 2, 2016 at 3:51:12 PM UTC-5, fugee ohu 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
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a7a7a299-49d0-4475-b7f7-a83397afac37%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 2, '16 at 8:51p
activeJan 3, '16 at 1:40a
posts14
users3
websiterubyonrails.org
irc#RubyOnRails

3 users in discussion

Fugee ohu: 9 posts Jelinek: 3 posts Colin Law: 2 posts

People

Translate

site design / logo © 2021 Grokbase