Ruby On Rails in Richmond, TX
Hi Raghavendra,
I'm trying to create a dog pedigree application and got stuck in the functionality that allows a user to add his dog as another's dog relative (sibling, parent, grand-parent, etc). I need help creating a form within the dog/show.html.erb page that allows a user to add his dog as a relative to the dog in the profile as in this picture (url available after purchase)
Also help with the pedigree_controller.rb methods if they fail. currently they look like this:
Here is a link to the StackOverflow page where I include more details: (url available after purchase)#33577337
class PedigreeController < ApplicationController
def create
@dog = Dog.find(params[:dog_id])
#@pedigree = pedigrees.build(dog_id: @dog.id, relative_id: @dog.id, relation_name: :string)
@pedigree = @dog.build_pedigree(pedigree_params)
if @pedigree.save
flash[:success] = "Dog relative added."
redirect_to access_dogmenu_path
else
flash[:danger] = "Unable to add this dog as relative"
redirect_to access_dogmenu_path
end
end
def destroy
@pedigree = @dog.pedigrees.find(params[:id])
@pedigree.destroy
flash[:success] = "Relative removed."
redirect_to access_dogmenu_path
end
private
def pedigree_params
params.require(:pedigree).permit(:dog_id, :relative_id, :relation_name)
end
end
Sent by Diego on 11/9/15
Setup FREE profile
to buy Diego's job about Ruby On Rails in Richmond, TX
Tanya Zalman
- Zhanna was a patient and qualified homework help to my daughter.
Zhanna not only tutored most elementary subjects but also spoke and taught her in Russian — our native language.
by Tanya Zalman,
San Jose, CA
More Testimonials