sql - How to perform such join tables in ActiveRecord? -
I need help to include using ActiveRecord relationship models:
Select "Access_urls" Eddie "," Kantrolr_arls. "" controller "," Akshn_rlls "." Akshn_rlls "from" action "internal" Niyntrk_arls "are included in" Niyntrk_arls "." id "=" access_urls "." Kantrolr_ril_aid "inner "Action" = "access_rl" on join_action_action "action_arles" "Akshn_ril_aidi" where I have access URL, Akshnuarel and controller URL model
Class AccessUrl & lt; ActiveRecord :: Base is_to: controller_url belongs_to: action_url and class actionUrl & lt; ActiveRecord :: Base is_my: access_urls is valid: action, presence: true, specification: {message: "já encontra-se em uso." } End Class Controller URL & lt; ActiveRecord :: Base has_many: access_urls valid controller, presence: the truth, specificity: {message: "já encontra-se em uso." } Can anyone help me?
Use:
results = AccessUrl.joins (: controller_url, : Action_url). Select ( 'access_urls.id, controller_urls.control, action_urls.action') This will make relations with you Result with AccessUrl . You can loop through results and access them to the selected columns: result.each do | R | # RID #RControl #R.ACAP End
Comments
Post a Comment