0

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]"])

3 Answers 3

5

Try this:

news = News.find(:all, :conditions => ["simulation_id = ? AND created_at > ?", session[:sim_id], session[:last_login]])
Sign up to request clarification or add additional context in comments.

Comments

1

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]]

1 Comment

simulation_id should be '=', not '=>'
0

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]])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.