On 27 May 2014 11:26, Alessandra Poblador <lists@ruby-forum.com> wrote:
> Hi there-
>
> I am a Ruby on Rails beginner trying to work with 2 models, of the
> relationship:
> [user] has_many [user_details]
>
> I would like to configure my app so that on the create user form, there
> are certain default user_details that are created at the same time. I
> attempted to perform this by building user_details in the new user
> action in the user controller, and then displaying text fields for each
> user_detail in the new user form. However, for some reason it seems that
> the user_details are not being saved when the form is submitted. The
> form redirects to the show user page, and no user_detail fields are
> shown.
The first thing to do is to work out which bit of code is failing.
First look in log/development.log where you can see the action
requests, sql details and so on. If the request looks ok then you can
debug your code to find out what is going on. Ideally one should use
a debugger such as pry, but one simple way is to insert puts
statements in the code showing the values of data and so on, These
will be printed in the server terminal window. You have to be a
little careful here as, due to buffering, the print may seem to be
slightly out of sync with the surrounding server data.
I presume that you have already worked right through a tutorial such
as railstutorial.org (which is free to use online), which will show
you the basics of rails.
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%3D0gLuu40eJ0sc3ZDVK9_6L%2BYgW1frfHObcQP8_9-Tof7Y0Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment