Search code examples
ruby-on-railsrubyrjs

Ruby 'if' condition in rjs


I want to insert a user in the userlist only if the user object (@row) is not nil. How do I do the insert conditionally in an rjs template?

page.insert_html :bottom, :userlist, render(:partial => "user", :locals => { :user => @row, :myid => @row.id })

thanks much.


Solution

  • page.insert_html :bottom, :userlist, render(:partial => "user", :locals =>  { :user => @row, :myid => @row.id }) unless @row.blank?