Ruby on Rails Saturday, January 2, 2016


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> 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 <fuge...@gmail.com> 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.
To post to this group, send email to rubyonra...@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.

    @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.

No comments:

Post a Comment