0
Java 응용 프로그램의 원격 데이터베이스에 내 Rails 응용 프로그램을 연결해야합니다.Refactoring SQL
은이 같은 쿼리를 가지고 :
나중에 복잡한 추가 싶어서, 아칸소 번호 찾기() 메소드로 리팩토링 할 필요가find_by_sql("select c_templateid, c_templateinfoid, c_startdate, c_enddate, c_active,
campaign, shortcode, prefix, c_descriptivename, c_description, c_templatename
from (active_services aser join activity a on aser.c_primaryprefixid =
a.c_primaryprefixid) join matrix_templateinfo using(c_templateinfoid)
where campaign is not null)")
: 거기에 조건을. 그 문자열을 나중에 find_by_sql 메소드에 추가하기 위해 문자열로 변환하고 싶지 않습니다.
:joins => "matrix_templateinfo ON <conditions go here> AND campaing IS NOT NULL"
에 합류하지만 당신은 정말 당신이 레일을 사용하는 경우 귀하의 필드 이름을 padronizing 시작해야합니다 :에
find(:all,
:select => "c_templateid, c_templateinfoid, c_startdate, c_enddate, c_active,
campaign, shortcode, prefix, c_descriptivename, c_description, c_templatename",
# :joins => WHAT I SHOULD DO HERE ?
:conditions => "campaign is not null"
)
내가 리팩토링 한 그것은 HTTP ://gist.github.com/487539,하지만이 검색어는 같은지 모르겠습니다. – astropanic