lundi 13 avril 2015

Controller/view for Popup (dialog) form on RAILS HOW-TO

I'm building an e commerce website where user can upload his products. A product is basically a picture with a few attributs.


I've implemented Jquery Dialog so that when User click on a button in the navbar , a form popup to create a new product wherever he is on the website.


The way i've implemented it seemed pretty shaky to me so i would like some input on how to do it properly.


I have a product controller with a "create" route that create a new product based on attributs.


In my application.html.erb where i have my navbar , i also have an hidden form that jquery use when clicked on the "create a product" button.


It seemed weird to me to have a form at the end of my application view even tho nobody will ever see it there.


Where should i put it if not in my app view so that it's accessible everywhere ?


I'm also having similar problems with my controller. I'm currently using form_tag in my view to products_path and it's working,but i might have to switch to form_for, and comes the problem of the post path form my form in the new form. @product doesn't work , :product either. It seems that it never hit the product#create controller.And it's obvious.


Should i move my product#create controller into application controller? again seems pretty bad.


If anyone can point me in the right direction. That would be greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire