On 25 November 2015 at 23:29, fugee ohu <fugee...@gmail.com> wrote:
> in this example what if i didn't have a values for science, physics and
> gravity but had to get it from form what field would i use? my guess any of
> the 3 variables can be substituted with params[:id] ?
>
> Create a root node:
>
> science = Category.create!(:name => 'Science')
>
> Put a new thing inside this root node:
>
> physics = Category.create!(:name => 'Physics')
> physics.move_to_child_of(science)
>
> Put another thing inside the "physics" node:
>
> gravity = Category.create!(:name => 'Gravity')
> gravity.move_to_child_of(physics)
>

Again, unfortunately, I have little idea of exactly what you are
asking.  If the form is generated by
form_for @category
then 'name' would be one of the fields expected to be in the form, so
you should be able to do
Category.create!(params[:category])
though it would be more usual to use new and save and then check the
return value of save in case there were validation errors.

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+unsubscr...@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%3D0gLs_33Ns_JM2X8zoFgjO%3D_F0oUih9jgJ-ND0vzJ1-OyKQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to