ruby on rails - How can I get the carousel to work in landing_page.html.erb without changing the products index view? -
i'm trying pull first 3 or 4 products database , display them individual slides, content (image, name, description, link) populated dynamically. if products ever updated, new ones appear on homepage without needing modify code. i'm getting error in screen shot attached. changed landing_page.html.erb @ https://gist.github.com/faisal-hassan/fc0f19c6efe3fe8756d4 , products controller @ https://gist.github.com/faisal-hassan/828793f22ebb88fcbcc6. products index , rest of unchanged files on @ https://github.com/faisal-hassan/vzncommerce .
you have controllers messed up. page using (landing_page
) under static pages
controller. therefore, code loads @products
object should in static pages
controller, not in products
controller.
in static pages
controller, landing_page
code should this:
class staticpagescontroller < applicationcontroller def landing_page @products = product.limit(3) end end
Comments
Post a Comment