I am trying to use hpricot in a controller. I would like to pass this value to a html.erb page so I can display 开发者_开发知识库it on the screen
So I wrote this:
session[:allcars] = (doc/"td.car_title/text()")
but this gives an error
when I tried this:
puts (doc/"td.car_title/text()")
this printed the cars into the console.
So I can't understand what I'm doing wrong :S
Thanks
The easiest way to pass variables from a controller to a view is to use a member variable.
@allcars = (doc/"td.car_title/text()")
Then in your html.rb page, get the value using @allcars
.
精彩评论