Question

Where is the error in this I can't see it:

news = News.find(:all, :conditions => [":simulation_id => session[:sim_id] AND :created_at > session[:last_login]"])
Was it helpful?

Solution

Try this:

news = News.find(:all, :conditions => ["simulation_id = ? AND created_at > ?", session[:sim_id], session[:last_login]])

OTHER TIPS

Your conditions string won't be evaluated as you expect:

[":simulation_id => session[:sim_id] AND :created_at > session[:last_login]"]

change that to

["simulation_id = ? AND created_at > ?", session[:sim_id], session[:last_login]]

You can also call Model.all instead of Model.find(:all) which would look something like this:

news = News.all(:conditions => ["simulation_id = ? AND created_at > ?", session[:sim_id], session[:last_login]])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top