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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.